Add Formula to Cell With VBA Macro Code
-
-
-
-
-
Re: Add Formula to Cell With VBA Macro Code
Hi there. I tried the following modified code:
CodeRange("B16").Formula = "=DATE(YEAR(" & Cells(16, 1) & "),MONTH(" & Cells(16, 1) + 1 & "),0)" 'where cells(16,1).value="Feb-2007"
but the formula in the cell turned out to be:
=DATE(YEAR(1/2/2007),MONTH(2/2/2007),0)
and the result : 00/01/1900Any advice please?
-
Re: Add Formula to Cell With VBA Macro Code
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...try
If you are using R1C1 cell reference or
if not
-
Re: Add Formula to Cell With VBA Macro Code
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!
-
Re: Add Formula to Cell With VBA Macro Code
[QUOTE]The best way is to Record a Macro Entering the needed formula.QUOTE]
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!