brocazaria
New Member
- Joined
- Mar 12, 2020
- Messages
- 2
- Office Version
- 2019
- Platform
- Windows
I've attached my code below. The code works as I intended, but after running it displays the error "Runtime error '1004' no cells were found".
Basically I want the code to change cell G3 to display today's date and return the value, if the formula in cell F3 changes. Anyone have any suggestions as to how to get rid of the error, or show me how to make the code run properly?
Private Sub Worksheet_Change(ByVal Target As Range)
' When cell G3 (a formula referencing other cells) is changed, run the code
' Changes cell G3 to post the current date and time and return the value
If Target.Dependents.Address = Range("F3").Address Then
'
' NOW Macro
' Makes the cell display today's date
'
Range("G3").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Range("G3").Select
Selection.NumberFormat = "d-mmm h:mm"
'
' PasteVal Macro
' Copies the current cell and pastes the value
'
Range("G3").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End If
End Sub
Basically I want the code to change cell G3 to display today's date and return the value, if the formula in cell F3 changes. Anyone have any suggestions as to how to get rid of the error, or show me how to make the code run properly?
Private Sub Worksheet_Change(ByVal Target As Range)
' When cell G3 (a formula referencing other cells) is changed, run the code
' Changes cell G3 to post the current date and time and return the value
If Target.Dependents.Address = Range("F3").Address Then
'
' NOW Macro
' Makes the cell display today's date
'
Range("G3").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Range("G3").Select
Selection.NumberFormat = "d-mmm h:mm"
'
' PasteVal Macro
' Copies the current cell and pastes the value
'
Range("G3").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
End If
End Sub