What would clear data macro do?
Short answer = Clear the Data on each Day-N sheet in cols ABCEGI
Also protects cells, adds data validation, some formatting
Option Explicit
Sub UnprotectAll()
Dim i As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
For i = 1 To 31
Worksheets("Day " & i).Unprotect
Next i
End Sub
Sub ForceUpdate()
Dim rAllNames As Range, rNames As Range, rName As Range
Dim ws As Worksheet
Dim i As Long, iName As Long
If MsgBox("Force an Update of Statistics?", vbYesNo + vbQuestion + vbDefaultButton2, "Force Update") = vbNo Then
Exit Sub
End If
Application.ScreenUpdating = False
Application.EnableEvents = False
Set rAllNames = Worksheets("Individuals").Range("A2")
Set rAllNames = Range(rAllNames, rAllNames.End(xlDown))
Set rAllNames = rAllNames.Resize(rAllNames.Rows.Count, 2)
For i = 31 To 1 Step -1
With Worksheets("Day " & i)
If Len(.Range("A6").Value) = 0 Then GoTo NextDay
Set rNames = .Range("A6")
Set rNames = Range(rNames, .Cells(.Rows.Count, 1).End(xlUp))
For Each rName In rNames.Rows
iName = -1
On Error Resume Next
iName = Application.WorksheetFunction.Match(rName.Cells(1, 1).Value, rAllNames.Columns(1), 0)
On Error GoTo 0
If iName <> -1 Then
If Len(rAllNames.Cells(iName, 2).Value) = 0 Then
rAllNames.Cells(iName, 2).Value = rName.Cells(1, 2).Value
End If
End If
Next
End With
NextDay:
Next i
End Sub
Sub ClearAndReset()
Dim rNames As Range
Dim ws As Worksheet
Dim i As Long
If MsgBox("Clear Data and Reset Formats?", vbYesNo + vbQuestion + vbDefaultButton2, "Clear Data") = vbNo Then
Exit Sub
End If
Set rNames = Worksheets("Individuals").Range("A2")
Set rNames = Range(rNames, rNames.End(xlDown))
Application.ScreenUpdating = False
Application.EnableEvents = False
For i = 1 To 31
rNames.Offset(, 1).ClearContents
With Worksheets("Day " & i)
.Select
.Unprotect
.Rows("6:6").Select
ActiveWindow.FreezePanes = False
ActiveWindow.FreezePanes = True
Application.CutCopyMode = False
.Cells.Locked = True
.Range("A3").Locked = False
.Range("A6:A44").Locked = False
.Range("C6:C44").Locked = False
.Range("E6:E44").Locked = False
.Range("G6:G44").Locked = False
.Range("I6:I44").Locked = False
.Range("A6:A44").ClearContents
.Range("B6:B44").ClearContents
.Range("C6:C44").ClearContents
.Range("E6:E44").ClearContents
.Range("G6:G44").ClearContents
.Range("I6:I44").ClearContents
.Columns("M:XFD").Hidden = True
With .Range("A6:A44").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _
Formula1:="=" & rNames.Parent.Name & "!" & rNames.Address(True, True)
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, UserInterfaceOnly:=True
.EnableSelection = xlUnlockedCells
End With
Next i
Worksheets("Day 1").Select
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub