J
Juan Correa
Hello,
I have this bit of code that is part of a larger macro:
' Populate the Month Column with new Monts
.Range(.Cells(2, LastCol + 1), .Cells(LastRow, LastCol +
1)).Formula = _
"=IF(MONTH(H2)=12,CurrentPeriod(H2),IF(H2<=LastFriday(H2),CurrentPeriod(H2),NextPeriod(H2)))"
.Range(.Cells(2, LastCol + 1), .Cells(LastRow, LastCol +
1)).NumberFormat = "MM-YYYY"
What this does is populate the column to the right of the last used column
in my data spreadsheet with a formula that does some checks on the dates
stored on column H and outputs another date based on them.
As you can see right now I have it hard-coded to column H.
The issue that I have is that the report may vary in the number of columns
included and the date to be evaluated may not always be on column H. The one
constant that I have is the column label.
So I though about doing something like:
myColumn = Cells.Find(What:="Column Label").Column
and then changing the formula to the cells(R, C) format...
Here is where I'm running into problems with the syntax.
Can someone show me what the correct syntax would be?
thanks
Juan Correa
I have this bit of code that is part of a larger macro:
' Populate the Month Column with new Monts
.Range(.Cells(2, LastCol + 1), .Cells(LastRow, LastCol +
1)).Formula = _
"=IF(MONTH(H2)=12,CurrentPeriod(H2),IF(H2<=LastFriday(H2),CurrentPeriod(H2),NextPeriod(H2)))"
.Range(.Cells(2, LastCol + 1), .Cells(LastRow, LastCol +
1)).NumberFormat = "MM-YYYY"
What this does is populate the column to the right of the last used column
in my data spreadsheet with a formula that does some checks on the dates
stored on column H and outputs another date based on them.
As you can see right now I have it hard-coded to column H.
The issue that I have is that the report may vary in the number of columns
included and the date to be evaluated may not always be on column H. The one
constant that I have is the column label.
So I though about doing something like:
myColumn = Cells.Find(What:="Column Label").Column
and then changing the formula to the cells(R, C) format...
Here is where I'm running into problems with the syntax.
Can someone show me what the correct syntax would be?
thanks
Juan Correa