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
 
Yes, but I have an existing worksheet_change that hides unused rows.
It seems it is conflicting with the This Workbook code?
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Private Sub CommandButton1_Click()
With Range("C17:C310")
.EntireRow.Hidden = False
For Each cell In Range("C17:C" & ActiveCell.SpecialCells(xlCellTypeLastCell).Row)
Select Case cell.Value
Case Is = ""
cell.EntireRow.Hidden = True
End Select
Next cell
End With
End Sub


Sub Worksheet_Change(ByVal Target As Range)
'Forces text to Proper case for the range
If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
On Error Resume Next
If Not Intersect(Target, Range("G8:G310")) Is Nothing Then
Application.EnableEvents = False
Target = StrConv(Target, vbProperCase)
Application.EnableEvents = True
End If
'Unhides worksheets as per user
If Worksheets("Sheet1").Range("G8") = "Yes" Then
Worksheets("Sheet2").Visible = True
Else: Worksheets("Sheet2").Visible = False
End If
If Worksheets("Sheet1").Range("G9") = "Yes" Then
Worksheets("Sheet3").Visible = True
Else: Worksheets("Sheet3").Visible = False
End If

If Worksheets("Sheet1").Range("G10") = "Yes" Then
Worksheets("Sheet4").Visible = True
Else: Worksheets("Sheet4").Visible = False
End If


'Hide blank rows
With Range("C17:C372")
.EntireRow.Hidden = False
For Each cell In Range("C17:C" & ActiveCell.SpecialCells(xlCellTypeLastCell).Row)
Select Case cell.Value
Case Is = ""
cell.EntireRow.Hidden = True
End Select
Next cell
End With

On Error GoTo 0
End Sub
 
Upvote 0
Try this...

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim cell As Range
    [COLOR="Red"]Application.EnableEvents = False[/COLOR]
    For Each cell In Sheets("Sheet1").Range("H34:H310").SpecialCells(xlCellTypeFormulas)
        If cell.Value <> "" Then cell.Value = cell.Value
    Next cell
    [COLOR="Red"]Application.EnableEvents = True[/COLOR]
End Sub
 
Upvote 0
Alpha I don't think it will work unless there are cells that need changing,
If specialcells doesn't find anything it falls down
 
Upvote 0
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim cell As Range
    On Error GoTo ReEnable
    Application.EnableEvents = False
    For Each cell In Sheets("Sheet1").Range("H34:H310").SpecialCells(xlCellTypeFormulas)
        If cell.Value <> "" Then cell.Value = cell.Value
    Next cell
ReEnable:
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,025
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