data enters date in next cell for several columns

  • Thread starter Thread starter HELP ME PLEASE
  • Start date Start date
H

HELP ME PLEASE

enter 1 in a cell and it enters static date in next...Have this working in
one column with the following but need to have it work in columns Y:Y and
AA:AA also any one know how?

Private Sub Worksheet_General(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("U:U")) Is Nothing Then
Application.EnableEvents = False
If Target.Value = 1 Then
Target.Offset(0, 1).Value = Date
End If
Application.EnableEvents = True
End If
End Sub
 
One way. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target.Value) Then Exit Sub
If Target.Column = 21 Or _
Target.Column = 25 Or _
Target.Column = 27 Then
Application.EnableEvents = False
If Target.Value = 1 Then _
Target.Offset(0, 1).Value = Date
Application.EnableEvents = True
End If
End Sub
 
Thank alot. This works will the date remain static and not change tommorrow?
 
That code will not work in any worksheet or column using the event

Worksheet_General
Private Sub Worksheet_General(ByVal Target As Range) needs to be

Private Sub Worksheet_Change(ByVal Target As Range)

To work on more columns change the If Not Intersect line to

If Not Intersect(Target, Range("U:U,Y:Y, AA:AA")) Is Nothing Then

Static means "not changing" among other definitions.


Gord Dibben MS Excel MVP
 
thanks Gord, I plugged in Ottos script and it worked i will make your
upgrades and let u know how it works
 
Otto's code is fine.

No need to change.......just a different way of doing the same thing.

I find my method saves the IF/OR statements and I'm lazy<g>


Gord
 
The date cell does not contain a formula, just the date. It doesn't change.
Otto
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top