Hi all
I had some help the other day with clearing the ranges on all of the unlocked cells in my workbook. Another issue has come up and I am wondering if someone can help me with this. When the ranges on the sheet are cleared, I want to "reset" the date as well. I have almost no programming skills, a little in C++ and a little in C#, but none in vb. Below is the code I am using, which is compiling wrong, and the worksheet is attached. It's a basic sheet. The first code is activated by a button. The second code, I thought, would be activated through the other code. Thanks in advance.
Private Sub button_Delete_Click()
Dim response
Dim AllSheet
response = MsgBox("You are about to clear all numbers. Proceed? R", vbYesNo)
If response = vbYes Then
Application.ScreenUpdating = False
For Each AllSheet In ActiveWorkbook.Worksheets
Sheets(AllSheet.Name).Activate
ActiveSheet.UsedRange.Select
For Each rng In Selection
If rng.Locked = False Then
rng.ClearContents
End If
Next rng
Next AllSheet
End If
ResetDate()
Sheets(1).Activate
Range("E23").Select
Application.ScreenUpdating = True
End Sub
Private Sub ResetDate()
Dim AllSheet
For Each AllSheet In ActiveWorkbook.Worksheets
Sheets(AllSheet.Name).Activate
Range("J2").Select
For Each rng In Selection
rng.ClearContents
ActiveCell = Format$(Format$(ActiveCell, "##/##/####"), "dd/mm/yyyy")
ActiveCell = TODAY()
Next rng
Next AllSheet
End Sub
Bookmarks