English 中文(简体)
改写日期
原标题:Trouble with getting DateAdd to correctly formulate
  • 时间:2011-11-21 18:01:21
  •  标签:
  • vba
  • excel

因此,我有两个问题,我似乎无法无动于衷。 我从一张基于模板的主纸上接过报告,每张编印本将有不同的浏览量。 每个填写表都有两栏(一栏为[F栏],一栏为满日期[H栏])。 每一行的编号为F栏,都需要增加60天,并将日期列入H栏。 我努力做到:

Dim cell As Range 
For Each cell In Selection  
cell.Value = cell.Value + 60
Next cell

I have tried this also with combinations of different while statements that I use for other things where I am putting values in one column based off of another, but I can t get them to work either.

我遇到的一些问题是:首先,当我确实设法让它进入H室的日期时,它总是进入第29/1900号。 如果在F栏中注明日期,或该日期。 第二,当我试图为甄选确定一个范围时(这是我试图结合“While”陈述时),它在整个范围留下一个日期,而不只是在F栏中注明日期。

如果在F栏中有一个日期,我怎么能够只增加H栏的一个日期,我怎样才能得到收入,来正确增加60天?

最佳回答
Sub Tester()

Dim c As Range, val

    For Each c In ActiveSheet.Range("E2:E100")
        val = c.Value
        If Len(val) > 0 And IsDate(val) Then
            c.Offset(0, 2).Value = val + 60
        End If
    Next c

End Sub
问题回答

暂无回答




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签