Add day to date in VBA????

C

Chris Watson

I need to add 7 days to a date I have in a cell using VBA.
I have a Command Button that I want to clear specific cells and add
7days to a date and increace a week number by 1, Is it possible the
have a VBA code that will do all this on a command button. The Week
Number cell on the worksheet is A1, the date is B1, and the specific
cell I want to clear is A2,C6,C8,D9,F2,F5, and B10.
 
G

Guest

Chris
Here's some suggestions
Presuming you wanted to write the Date+7 into Cell C1, could use the followin
Activesheet.Range("C1").Formula = "=B1+7"
To increment A1 by 1
Activesheet.Range("A1").Formula = Activesheet.Range("A1").Value + 1
To clear those Cells
Activesheet.Range("A2,C6,C8,D9,F2,F5").ClearContents

Hope this helps

Nick
 
A

Ardus Petus

(untested code):

'------------------------------------
With Range("A1")
.Value = .Value + 1
End With

With Range("B1")
.Value = .Value + 7
End With

Range("A2,C6,C8,D9,F2,F5,B10").ClearContents
'-----------------------------------

HTH
--
AP

"Chris Watson" <[email protected]> a
écrit dans le message de
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top