Date Stamp with IfStament

uclc1922

New Member
Joined
Nov 1, 2012
Messages
15
I would like to put a Date Stamp in G:G IF A:A or B:B = 1


Bellow is what I have so far.... Thank You greatly in advance...


Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
For Each Cell In Target
With Cell
If .Column = Range("A:a").Column Then
Cells(.Row, "F").Value = Int(Now)
End If
End With
Next Cell
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
Application.EnableEvents = False
For Each c In Target
    If c.Column = 1 Or c.Column = 2 Then Range("G" & c.Row).Value = Date
Next c
Application.EnableEvents = True
End Sub
 
Upvote 0
Thank You this works great ! Can you help me in one more time? Cells a3:b32 will only ever have a 1 or be "" can the code be written to date stamp f3:f32 if a3:b32 contain the number 1 and to delete the date stamp if the number 1 is deleted?

Thanks In Advance
 
Upvote 0
Perhaps

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
Application.EnableEvents = False
For Each c In Target
    If c.Column = 1 Or c.Column = 2 Then
        If c.Value = "" Then
            Range("F" & c.Row).ClearContents
        Else
            Range("F" & c.Row).Value = Date
        End If
    End If
Next c
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top