ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date in VBA (https://www.excelbanter.com/excel-programming/359734-date-vba.html)

StephanieH

Date in VBA
 
I have the following If then statements:
If PublishMonth = "10/1/2005" Then MsgBox ("Add C1ANC Goals to Actuals, 1-3
and 4-6 (use N/A)")
If PublishMonth = "2/1/2006" Then MsgBox ("Remove N/A. Use C1ANC's batch
numbers")
If PublishMonth = "3/1/2006" Then MsgBox ("Add 7-9 and adjust to leader's.
Remove N/A. ")
If PublishMonth = "4/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "5/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "6/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "7/1/2006" Then MsgBox ("Adjust 10-12 to leader's")
If PublishMonth = "8/1/2006" Then MsgBox ("Adjust 10-12 to leader's")
If PublishMonth = "9/1/2006" Then MsgBox ("Adjust 10-12 to leader's")

Instead of counting out 6 months from 10/1/05 and entering 2/1/06 into the
statement, how can I have VBA figure 6 months from 10/1/05? Something like
If PublishMonth = 10/1/05 + 6 then ......
If PublishMonth = 10/1/05 + 7 then ......



Don Guillett

Date in VBA
 
this idea should help you.

Sub addmonth()
pm = "10/1/2006"
MsgBox DateSerial(Year(pm), Month(pm) + 6, Day(pm))
End Sub


--
Don Guillett
SalesAid Software

"StephanieH" wrote in message
...
I have the following If then statements:
If PublishMonth = "10/1/2005" Then MsgBox ("Add C1ANC Goals to Actuals,
1-3
and 4-6 (use N/A)")
If PublishMonth = "2/1/2006" Then MsgBox ("Remove N/A. Use C1ANC's batch
numbers")
If PublishMonth = "3/1/2006" Then MsgBox ("Add 7-9 and adjust to leader's.
Remove N/A. ")
If PublishMonth = "4/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "5/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "6/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "7/1/2006" Then MsgBox ("Adjust 10-12 to leader's")
If PublishMonth = "8/1/2006" Then MsgBox ("Adjust 10-12 to leader's")
If PublishMonth = "9/1/2006" Then MsgBox ("Adjust 10-12 to leader's")

Instead of counting out 6 months from 10/1/05 and entering 2/1/06 into the
statement, how can I have VBA figure 6 months from 10/1/05? Something like
If PublishMonth = 10/1/05 + 6 then ......
If PublishMonth = 10/1/05 + 7 then ......





StephanieH

Date in VBA
 
Yes it does. Thanks.

"Don Guillett" wrote:

this idea should help you.

Sub addmonth()
pm = "10/1/2006"
MsgBox DateSerial(Year(pm), Month(pm) + 6, Day(pm))
End Sub


--
Don Guillett
SalesAid Software

"StephanieH" wrote in message
...
I have the following If then statements:
If PublishMonth = "10/1/2005" Then MsgBox ("Add C1ANC Goals to Actuals,
1-3
and 4-6 (use N/A)")
If PublishMonth = "2/1/2006" Then MsgBox ("Remove N/A. Use C1ANC's batch
numbers")
If PublishMonth = "3/1/2006" Then MsgBox ("Add 7-9 and adjust to leader's.
Remove N/A. ")
If PublishMonth = "4/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "5/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "6/1/2006" Then MsgBox ("Adjust 7-9 to leader's")
If PublishMonth = "7/1/2006" Then MsgBox ("Adjust 10-12 to leader's")
If PublishMonth = "8/1/2006" Then MsgBox ("Adjust 10-12 to leader's")
If PublishMonth = "9/1/2006" Then MsgBox ("Adjust 10-12 to leader's")

Instead of counting out 6 months from 10/1/05 and entering 2/1/06 into the
statement, how can I have VBA figure 6 months from 10/1/05? Something like
If PublishMonth = 10/1/05 + 6 then ......
If PublishMonth = 10/1/05 + 7 then ......







All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com