ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   last day of the month (https://www.excelbanter.com/excel-programming/340834-last-day-month.html)

JT

last day of the month
 
Is there a way to automatically fill a variable with the last day of the
month based on the month in another variable?

For example, if var1 = 9, is there a way to program var2 = 9/30/2005 or if
var1 = 8, then var2= 8/31/2005

Thanks.......
--
JT

Bob Phillips[_6_]

last day of the month
 
var2 = dateserial(2005,var1+1,0)

--
HTH

Bob Phillips

"JT" wrote in message
...
Is there a way to automatically fill a variable with the last day of the
month based on the month in another variable?

For example, if var1 = 9, is there a way to program var2 = 9/30/2005 or if
var1 = 8, then var2= 8/31/2005

Thanks.......
--
JT




JT

last day of the month
 
Thanks for the help........This community is a terrific resource
--
JT


"Bob Phillips" wrote:

var2 = dateserial(2005,var1+1,0)

--
HTH

Bob Phillips

"JT" wrote in message
...
Is there a way to automatically fill a variable with the last day of the
month based on the month in another variable?

For example, if var1 = 9, is there a way to program var2 = 9/30/2005 or if
var1 = 8, then var2= 8/31/2005

Thanks.......
--
JT





Norman Jones

last day of the month
 
Hi JT,

Try something like:

Sub AAA()
Dim var As Long
Dim LastDayOfMonth As Date

var = 8

LastDayOfMonth = DateSerial(Year(Date), var + 1, 0)
MsgBox LastDayOfMonth

End Sub

---
Regards,
Norman



"JT" wrote in message
...
Is there a way to automatically fill a variable with the last day of the
month based on the month in another variable?

For example, if var1 = 9, is there a way to program var2 = 9/30/2005 or if
var1 = 8, then var2= 8/31/2005

Thanks.......
--
JT




NickHK

last day of the month
 
This is weird:
In Bob's reply I see "var2 = dateserial(2005,var1,0)" and was going to
correct it.
But then noticed in JT's quoted reply to Bob "var2 =
dateserial(2005,var+1,0)", correct.

Is it just my OE reader or anyone else seeing the same ?

NickHK

"Bob Phillips" wrote in message
...
var2 = dateserial(2005,var1,0)

--
HTH

Bob Phillips

"JT" wrote in message
...
Is there a way to automatically fill a variable with the last day of the
month based on the month in another variable?

For example, if var1 = 9, is there a way to program var2 = 9/30/2005 or

if
var1 = 8, then var2= 8/31/2005

Thanks.......
--
JT






Bob Phillips[_6_]

last day of the month
 
Nick, I had something like that the other day.

I posted a response, and the OP had a problem because parts of the text just
disappeared. I re-posted with the full text and she had no problem then.

--
HTH

Bob Phillips

"NickHK" wrote in message
...
This is weird:
In Bob's reply I see "var2 = dateserial(2005,var1,0)" and was going to
correct it.
But then noticed in JT's quoted reply to Bob "var2 =
dateserial(2005,var+1,0)", correct.

Is it just my OE reader or anyone else seeing the same ?

NickHK

"Bob Phillips" wrote in message
...
var2 = dateserial(2005,var1,0)

--
HTH

Bob Phillips

"JT" wrote in message
...
Is there a way to automatically fill a variable with the last day of

the
month based on the month in another variable?

For example, if var1 = 9, is there a way to program var2 = 9/30/2005

or
if
var1 = 8, then var2= 8/31/2005

Thanks.......
--
JT









All times are GMT +1. The time now is 05:37 PM.

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