Check for Not Empty Cells

Ivy_1011

New Member
Joined
Mar 19, 2021
Messages
18
Platform
  1. Windows
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
 
Are you creating several threads ... for the very same question ...???
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top