Hi,
I have the code below which works well. It checks to see if Cell "A1" is not empty if it is not empty then it runs the code only in the cells are blank in column A.
I would like to change the code so that it automatically checks each cell in column A, if has data then it runs the code. This code would add "0" to the empty cells.
Sub Empty_Cells()
'
Dim i As Long
Dim c As Long
Dim myRange As Range
Dim myCell As Range
Dim myCol As Range
Set myRange = Worksheets("Data").Range("A4:H12")
'I would like to change this line of code to a loop in column ("A5:A50") to check if the cell is Not Empty.
If Not IsEmpty(Range("A1").Value) = True Then
For Each myCell In myRange
c = c + 1
If IsEmpty(myCell) Then
myCell = 0
'myCell.Interior.Color = RGB(255, 87, 87)
i = i + 1
End If
Next myCell
MsgBox _
"There are total " & i & " empty cell(s) out of " & c & "."
'
End If
'
End Sub
I have the code below which works well. It checks to see if Cell "A1" is not empty if it is not empty then it runs the code only in the cells are blank in column A.
I would like to change the code so that it automatically checks each cell in column A, if has data then it runs the code. This code would add "0" to the empty cells.
Sub Empty_Cells()
'
Dim i As Long
Dim c As Long
Dim myRange As Range
Dim myCell As Range
Dim myCol As Range
Set myRange = Worksheets("Data").Range("A4:H12")
'I would like to change this line of code to a loop in column ("A5:A50") to check if the cell is Not Empty.
If Not IsEmpty(Range("A1").Value) = True Then
For Each myCell In myRange
c = c + 1
If IsEmpty(myCell) Then
myCell = 0
'myCell.Interior.Color = RGB(255, 87, 87)
i = i + 1
End If
Next myCell
MsgBox _
"There are total " & i & " empty cell(s) out of " & c & "."
'
End If
'
End Sub