think you're missing a bracket....tryVB:Range("B16").Formula = "=DATE(YEAR(" & Cells(16,1) & "),MONTH(" & Cells(16,1) +1 & "),0)"
Hello there. Can anyone please tell me what's wrong with the following vba code?
Cheers.VB:Range("B16").Formula = "=DATE(YEAR(" & Cells(16,1) & ",MONTH(" & Cells(16,1) +1 & ",0)"" where Cells(16,1) = "Feb-2007"
think you're missing a bracket....tryVB:Range("B16").Formula = "=DATE(YEAR(" & Cells(16,1) & "),MONTH(" & Cells(16,1) +1 & "),0)"
D![]()
Better a bad day on the water than a good day in the office
The best way is to Record a Macro Entering the needed formula.
Last edited by Dave Hawley; October 4th, 2006 at 17:38.
Hi there. I tried the following modified code:
but the formula in the cell turned out to be:VB:Range("B16").Formula = "=DATE(YEAR(" & Cells(16, 1) & "),MONTH(" & Cells(16, 1) + 1 & "),0)" 'where cells(16,1).value="Feb-2007"
=DATE(YEAR(1/2/2007),MONTH(2/2/2007),0)
and the result : 00/01/1900
Any advice please?
Not sure what you mean - the formula does what you'd asked for...
however...if you are trying to get a reference to the cell in the formula...tryIf you are using R1C1 cell reference orVB:Range("B16").Formula = "=DATE(YEAR(R16C1),MONTH(R16C1),0)"if notVB:Range("B16").Formula = "=DATE(YEAR($A$16),MONTH($A$16),0)"
D![]()
Better a bad day on the water than a good day in the office
Sorry. I've got a little muddle myself! The required formula should be created in range("B16) and the cell(r,c) should be the cell "A16" where Feb-2007 was stored.
Sorry for that!
[QUOTE]The best way is to Record a Macro Entering the needed formula.QUOTE]
There are currently 4 users browsing this thread. (0 members and 4 guests)
Bookmarks