Hi,
I’m using this macro and it works great, but it is giving me an error message if the ranges in m8:m47 on the status sheets 1/2 & 3 are blank?
Can anyone help me out to ignore blank cells in those 3 ranges?
Thanks
Sub NewButton_Click()
Dim fname As String
Application.ScreenUpdating = False
'fname = Range("J1") & Range("N1") & " " & Format(Range("L1"), "dd-mm-yyyy")
'ThisWorkbook.SaveAs ThisWorkbook.Path & "" & fname & ".xlsm", 52
Set cellrange1 = Range("M8:M47").Cells.SpecialCells(xlCellTypeConstants)
If Range("N1").Value = "1530" Then
Range("N1").Value = "0600"
Range("L1").Value = Range("L1").Value + 1
For Each cel In cellrange1
cel.Value = cel.Value + 1
Next
Else
Range("N1").Value = "1530"
End If
Sheets("Status Sheet 3502").Select
Set cellrange2 = Range("M8:M44").Cells.SpecialCells(xlCellTypeConstants)
If Range("N1").Value = "0600" Then
For Each cel1 In cellrange2
cel1.Value = cel1.Value + 1
Next
End If
I’m using this macro and it works great, but it is giving me an error message if the ranges in m8:m47 on the status sheets 1/2 & 3 are blank?
Can anyone help me out to ignore blank cells in those 3 ranges?
Thanks
Sub NewButton_Click()
Dim fname As String
Application.ScreenUpdating = False
'fname = Range("J1") & Range("N1") & " " & Format(Range("L1"), "dd-mm-yyyy")
'ThisWorkbook.SaveAs ThisWorkbook.Path & "" & fname & ".xlsm", 52
Set cellrange1 = Range("M8:M47").Cells.SpecialCells(xlCellTypeConstants)
If Range("N1").Value = "1530" Then
Range("N1").Value = "0600"
Range("L1").Value = Range("L1").Value + 1
For Each cel In cellrange1
cel.Value = cel.Value + 1
Next
Else
Range("N1").Value = "1530"
End If
Sheets("Status Sheet 3502").Select
Set cellrange2 = Range("M8:M44").Cells.SpecialCells(xlCellTypeConstants)
If Range("N1").Value = "0600" Then
For Each cel1 In cellrange2
cel1.Value = cel1.Value + 1
Next
End If