Forum Discussion
Carl_61
Nov 04, 2024Iron Contributor
Posting a date based on an event
Hello Forum, Does any one know of a way thru a formula to post a date into a cell based on an event happening on other sheet. I have a sheet that makes a random selection of people from my ...
Alikoc
Nov 10, 2024MCT
Hello Carl,
I think you can fix it by adding the following command. Can you try it and let me know?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim targetSheet As Worksheet
Dim dateColumn As Range
' Set target sheet where the date should be posted
Set targetSheet = ThisWorkbook.Sheets("Sheet2") ' Change "Sheet2" to the actual name
' Define the range where the paste event happens
Set dateColumn = Me.Range("B:B") ' Assuming you are pasting in column B on Sheet1
' Check if the pasted cells are in the specified range
If Not Intersect(Target, dateColumn) Is Nothing Then
' Find the first empty cell in the target column on the target sheet
Dim emptyRow As Long
emptyRow = targetSheet.Cells(targetSheet.Rows.Count, "A").End(xlUp).Row + 1 ' Adjust "A" as needed
' Post the current date in the target sheet
targetSheet.Cells(emptyRow, "A").Value = Date ' Adjust "A" to the desired column for the date
End If
End Sub
Best Regards,
Ali Koc