Date stamp when cell value changes

GDunn

Board Regular
Joined
Mar 24, 2009
Messages
51
Hi,

I would like to date stamp a range of cells in column H, when the value on the same row in column G is changed to = "Yes". Have created a Worksheet_Change, but am unable to fix the column H change part.

Private Sub Worksheet_Change(ByVal Target As Range)
With Range("G34:G310")
For Each Cell In Range("G34:G" & ActiveCell.SpecialCells(xlCellTypeLastCell).Row)
Select Case Cell.Value
Case Is = "Yes"
Cell("H34:H").Value = Int(Now)
End Select
Next Cell
End With
End Sub

Thanks in advance
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try something like this...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("G34:G310"), Target) Is Nothing Then
        If LCase(Target.Value) = "yes" Then Target.Offset(, 1).Value = Date
    End If
End Sub

It works if the user types in yes in G34:G310. It doesn't work if a formula returns Yes.
 
Upvote 0
Thanks Alpha.
Was looking for a date stamp when formula = "Yes". As vale will change from "No" to "Yes"
 
Upvote 0
What is the formula?

Does the user do something to another cell that causes the formula to return yes\no? If yes, what cell?

We could use that range to trigger off of.
 
Upvote 0
There are many variations. This is one example:

=IF(AND(C19<>"",Cabling!J11=""),"No","yes")
 
Upvote 0
Put this formula in H34 and copy it down to H310
Code:
=IF(G34="Yes",TODAY(),"")

Then put this in the ThisWorkbook module. It "locks in" the date from the formula when the workbook is saved.
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim cell As Range
    For Each cell In Sheets("Sheet1").Range("G34:G310").SpecialCells(xlCellTypeFormulas)
        If cell.Value <> "" Then cell.Value= cell.Value
    Next cell
End Sub

Change the "Sheet1" in the code to the name of the worksheet you want this to work on.
 
Upvote 0
Sorry. The code should be this...

Code:
For Each cell In Sheets("Sheet1").Range("[COLOR="Red"]H[/COLOR]34:[COLOR="Red"]H[/COLOR]310").SpecialCells(xlCellTypeFormulas)
 
Upvote 0
AlhpaFrog the solution works, but when I hit save it continualy loops through the range until I hit Escape.
Can this be fixed?

Thanks for your help
 
Upvote 0

Forum statistics

Threads
1,223,708
Messages
6,174,006
Members
452,542
Latest member
Bricklin

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