Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Trigger inserting Date (again!)

Rick supplied the following code. It populates col A with dates after I
enter a date (that will always be the first day of a given month).

It works great, but now I find myself having to amend it so as rather
than entering the "start" date in A1, I have to now insert that start
date in A3, then populate the dates from A4 down to A252.

I'd appreciate an amendment to Rick's code that allows a date entry in
A3 (rather than A1) to populate A4:A252 (rather than A2:A248) with dates
for every 3 hrs - 8 date entries for each day of a month.

I've tried the obvious, but my dates keep being inserted from A1.

Tks

Rick Rothstein wrote:
This should do it for you...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$1" And IsDate(Target.Value) Then
Range("A2:A248").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A1").Text) - 1) Step 8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A1").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Trigger inserting Date (again!)

Hi

Have you change A1 to A3 throughout the code?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$3" And IsDate(Target.Value) Then
Range("A4:A252").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A3").Text) - 1) Step 8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A3").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub

Regards,
Per

"Ricky" skrev i meddelelsen
...
Rick supplied the following code. It populates col A with dates after I
enter a date (that will always be the first day of a given month).

It works great, but now I find myself having to amend it so as rather than
entering the "start" date in A1, I have to now insert that start date in
A3, then populate the dates from A4 down to A252.

I'd appreciate an amendment to Rick's code that allows a date entry in A3
(rather than A1) to populate A4:A252 (rather than A2:A248) with dates for
every 3 hrs - 8 date entries for each day of a month.

I've tried the obvious, but my dates keep being inserted from A1.

Tks

Rick Rothstein wrote:
This should do it for you...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$1" And IsDate(Target.Value) Then
Range("A2:A248").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A1").Text) - 1) Step 8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A1").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Trigger inserting Date (again!)

Yep, but it populates from A1 after I enter the start date in A3, rather
than A4.

Cheers, Ricky

Per Jessen wrote:
Hi

Have you change A1 to A3 throughout the code?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$3" And IsDate(Target.Value) Then
Range("A4:A252").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A3").Text) - 1) Step 8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A3").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub

Regards,
Per

"Ricky" skrev i meddelelsen
...
Rick supplied the following code. It populates col A with dates after
I enter a date (that will always be the first day of a given month).

It works great, but now I find myself having to amend it so as rather
than entering the "start" date in A1, I have to now insert that start
date in A3, then populate the dates from A4 down to A252.

I'd appreciate an amendment to Rick's code that allows a date entry in
A3 (rather than A1) to populate A4:A252 (rather than A2:A248) with
dates for every 3 hrs - 8 date entries for each day of a month.

I've tried the obvious, but my dates keep being inserted from A1.

Tks

Rick Rothstein wrote:
This should do it for you...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$1" And IsDate(Target.Value) Then
Range("A2:A248").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A1").Text) - 1) Step 8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A1").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Trigger inserting Date (again!)

I see the problem, change from this:

With Cells(X , "A")

to this:

With Cells(X + 3, "A")

Regards,
Per

"Ricky" skrev i meddelelsen
. au...
Yep, but it populates from A1 after I enter the start date in A3, rather
than A4.

Cheers, Ricky

Per Jessen wrote:
Hi

Have you change A1 to A3 throughout the code?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$3" And IsDate(Target.Value) Then
Range("A4:A252").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A3").Text) - 1) Step 8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A3").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub

Regards,
Per

"Ricky" skrev i meddelelsen
...
Rick supplied the following code. It populates col A with dates after I
enter a date (that will always be the first day of a given month).

It works great, but now I find myself having to amend it so as rather
than entering the "start" date in A1, I have to now insert that start
date in A3, then populate the dates from A4 down to A252.

I'd appreciate an amendment to Rick's code that allows a date entry in
A3 (rather than A1) to populate A4:A252 (rather than A2:A248) with dates
for every 3 hrs - 8 date entries for each day of a month.

I've tried the obvious, but my dates keep being inserted from A1.

Tks

Rick Rothstein wrote:
This should do it for you...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$1" And IsDate(Target.Value) Then
Range("A2:A248").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A1").Text) - 1) Step
8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A1").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Trigger inserting Date (again!)

Thanks Per, that did the trick!

Cheers, Ricky

Per Jessen wrote:
I see the problem, change from this:

With Cells(X , "A")

to this:

With Cells(X + 3, "A")

Regards,
Per

"Ricky" skrev i meddelelsen
. au...
Yep, but it populates from A1 after I enter the start date in A3,
rather than A4.

Cheers, Ricky

Per Jessen wrote:
Hi

Have you change A1 to A3 throughout the code?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$3" And IsDate(Target.Value) Then
Range("A4:A252").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A3").Text) - 1) Step 8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A3").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub

Regards,
Per

"Ricky" skrev i meddelelsen
...
Rick supplied the following code. It populates col A with dates
after I enter a date (that will always be the first day of a given
month).

It works great, but now I find myself having to amend it so as
rather than entering the "start" date in A1, I have to now insert
that start date in A3, then populate the dates from A4 down to A252.

I'd appreciate an amendment to Rick's code that allows a date entry
in A3 (rather than A1) to populate A4:A252 (rather than A2:A248)
with dates for every 3 hrs - 8 date entries for each day of a month.

I've tried the obvious, but my dates keep being inserted from A1.

Tks

Rick Rothstein wrote:
This should do it for you...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long
If Target.Address = "$A$1" And IsDate(Target.Value) Then
Range("A2:A248").Clear
If Day(Target.Value) = 1 Then
For X = 1 To 8 * Day(DateAdd("m", 1, Range("A1").Text) - 1)
Step 8
With Cells(X, "A")
.Resize(8, 1).Value = Range("A1").Value + Int(X / 8)
With .Offset(7).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End With
Next
End If
End If
End Sub


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
Trigger inserting date Ricky Excel Programming 9 April 9th 09 01:30 PM
Using date as trigger for macro Mike Milmoe Excel Discussion (Misc queries) 3 May 10th 07 06:43 PM
Inserting rows on cell trigger AMK4[_29_] Excel Programming 0 February 1st 06 08:44 PM
Recurring annual events using a specific date as a trigger date Bamboozled Excel Worksheet Functions 1 June 6th 05 01:44 PM
Date Flag/Trigger Music Non Stop Excel Programming 1 September 9th 03 02:20 PM


All times are GMT +1. The time now is 02:27 PM.

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

About Us

"It's about Microsoft Excel"