Troubleshooting Date+1 in VB

nicolehalliday

Board Regular
Joined
May 19, 2010
Messages
56
Hi,
I could really use some help with my code, I know it's simple but I've tried many variations with no success.

In cell EE1 there is a date which is just entered as "03/15/2011". In code, I'd like to enter the next date, "03/16/2011" in EF1. In excel I can simply write "=EE1+1" to return the date. My code looks like this:

Code:
Sheets("highs").Range("EF1").Select
    ActiveCell.FormulaR1C1 = "=EE1 + 1"

For some reason it enters "='EE1' + 1" which returns #NAME?. Why are there brackets around the EE1? All my other variations turned out even worse... any help would be greatly appreciated, thanks!!!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try
Code:
Sheets("highs").Range("EF1").Formula = "=EE1 + 1"
(Use the Formula property, not the FormulaR1C1 property.)

<SUP>edit </SUP>BTW - your code would actually be [slightly] more robust if you do use the FormulaR1C1 property. But, in that case, you'd need to edit the formula string to be:

Code:
Sheets("highs").Range("EF1").FormulaR1C1 = "=RC[-1] + 1"
<SUB>/edit</SUB>
 
Last edited:
Upvote 0
Drop the R1C1, should be just ActiveCell.Formula = ...

Or even better, without selecting..try

Sheets("highs").Range("EF1").Formula = "=EE1 + 1"
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top