Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
JT JT is offline
external usenet poster
 
Posts: 234
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
count month when date is in day/month/year format ccKennedy Excel Worksheet Functions 6 April 30th 09 03:32 AM
excel to make the days cary over month to month automaticly GARY New Users to Excel 1 April 19th 08 06:05 PM
Excel 2003 month to month data change grid Chad[_2_] Excel Discussion (Misc queries) 2 February 15th 08 01:36 AM
Converting Month Number to Month Text Abbreviation Bob Excel Worksheet Functions 10 May 12th 07 04:11 AM
transfer cell $ amount to other sheet month-to-month without overc Colin2u Excel Discussion (Misc queries) 1 July 28th 05 02:36 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"