Hi
I have this macro and when I run it appears to be deleting the data and the gridlines but not the actual rows and thus not shifting all the data up together thats supposed to be there when complete.
Any ideas why?
I have this macro and when I run it appears to be deleting the data and the gridlines but not the actual rows and thus not shifting all the data up together thats supposed to be there when complete.
Any ideas why?
VBA Code:
Sub MonthEnd()
Dim rCl As Range, rDelete As Range
Dim sSht As String
sSht = InputBox("Enter new sheet name", "New Month Sheet")
If Len(sSht) = 0 Then
MsgBox "You must enter a name for the new sheet", vbCritical, "Quitting"
Exit Sub
''/// copy current sheet
Else: ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = sSht
For Each rCl In ActiveSheet.Range("AB10:AB9999").Cells
If rCl.Value = 0 Then
If rDelete Is Nothing Then
Set rDelete = Range("A" & rCl.Row, rCl)
Else: Set rDelete = Union(rDelete, Range("A" & rCl.Row, rCl))
End If
End If
Next rCl
If Not rDelete Is Nothing Then rDelete.Delete
MsgBox "Month End successfully completed", vbInformation, "Done"
End If
End Sub