Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA date conversion

I need help creating a script that will take a few ranges of cells
containing dates (A1:A30,C1:C30,E1:E30)
and convert the day in those cells to the last day of the month
(3/12/2010 becomes 3/31/2010)

Any help is greatly appreciated!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default VBA date conversion

Try this:

Sub EndMonthConversion()
Dim rng As Range
Dim cell As Range

Set rng = Range("A1:A30, C1:C30, E1:E30")

For Each cell In rng
cell = DateSerial(Year(cell), (Month(cell) + 1), 1) - 1
Next
End Sub

Regards,
Per


On 20 Nov., 20:39, Aaron wrote:
I need help creating a script that will take a few ranges of cells
containing dates (A1:A30,C1:C30,E1:E30)
and convert the day in those cells to the last day of the month
(3/12/2010 becomes 3/31/2010)

Any help is greatly appreciated!!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default VBA date conversion

cell = DateSerial(Year(cell), (Month(cell) + 1), 1) - 1

Or more simply... cell = DateSerial(Year(cell), Month(cell) + 1, 0)

--
Rick Rothstein (MVP - Excel)


"Per Jessen" wrote in message
...
Try this:

Sub EndMonthConversion()
Dim rng As Range
Dim cell As Range

Set rng = Range("A1:A30, C1:C30, E1:E30")

For Each cell In rng
cell = DateSerial(Year(cell), (Month(cell) + 1), 1) - 1
Next
End Sub

Regards,
Per


On 20 Nov., 20:39, Aaron wrote:
I need help creating a script that will take a few ranges of cells
containing dates (A1:A30,C1:C30,E1:E30)
and convert the day in those cells to the last day of the month
(3/12/2010 becomes 3/31/2010)

Any help is greatly appreciated!!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VBA date conversion

Thanks guys....works great!

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
Date Conversion Help Saucer Man Excel Programming 4 May 22nd 09 04:24 PM
Date Conversion billbrandi Excel Discussion (Misc queries) 3 July 23rd 07 03:58 AM
Date Conversion Ron Coderre Excel Programming 0 May 24th 07 11:22 PM
Date conversion Tom Excel Discussion (Misc queries) 7 January 2nd 07 09:47 PM
Date conversion Kristiaaan Excel Discussion (Misc queries) 5 July 30th 05 05:49 AM


All times are GMT +1. The time now is 10:57 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"