LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Help needed with altering dates and date formats in VBA

Put the following in the code module for the worksheet. You said Col H
is filled in as a result of entry in another column. If so, you will
need to change the 2nd half to use the appropriate column/offsets.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 7 Then 'col G
Target.Offset(0, -6) = DateAdd("m", 1, Target)
End If
If Target.Column = 8 Then 'col H
If IsEmpty(Target.Offset(0, -1)) Then
Target.Offset(0, -7) = DateAdd("yyyy", 1, Target)
Else
Target.Offset(0, -7) = DateAdd("m", 1, Target.Offset(0, -1))
End If
End If
End Sub

Hth,
Merjet


 
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
Dates in different formats David Biddulph[_2_] Excel Discussion (Misc queries) 0 December 8th 09 10:45 AM
Dates in different formats Pete_UK Excel Discussion (Misc queries) 0 December 8th 09 09:31 AM
dates and formats Jenny dev New Users to Excel 1 July 21st 08 04:03 PM
Macro behaves differently then when recorded and stuffs dates (or date formats) stephenb Excel Programming 5 November 14th 05 02:30 AM
Excel Addin altering date format on text file import RJ Lohan[_2_] Excel Programming 3 March 3rd 05 01:09 AM


All times are GMT +1. The time now is 03:03 AM.

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"