![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Arizona
Posts: 68
|
Can anyone tell me why this won't work???
-- Dim endcycle As Date Dim newstartcycle As Date newstartcycle = CDate(InputBox("Enter beginning date of billing cycle.")) endcycle = DateAdd(m, 1, newstartcycle) -- thanks in advance to whomever solves this! |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Arizona
Posts: 68
|
additionally, how can I use VBA to return a date that is the 1st of the next month?
e.g. 3/15 --> 4/1 8/15 --> 9/1 etc. Thanks again if you can answer this |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Add quotes around the 'm' in the DateAdd
Change: endcycle = DateAdd(m, 1, newstartcycle) to endcycle = DateAdd("m", 1, newstartcycle) |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Quote:
DateSerial(Year(endcycle), Month(endcycle) + 1, 1) Another is to use the EOMONTH function, but you have to set references to the Analysis ToolPak to call the function. |
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Location: Arizona
Posts: 68
|
THANKS!
I ended up cheating on the second part though: -- newstartcycle = InputBox("Enter beginning date of billing cycle.") endcycle = DateAdd("m", 1, newstartcycle) nextdate = DateAdd("m", 1, endcycle) duedate = DateAdd("d", -14, nextdate) -- it's not fancy, but it works, Thanks again. |
|
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
You may want to validate the date, i.e., application.inputbox....type:=1, at the very least, you'll get a number.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|