Hi,
The code below allows me to add zeros to a specific row. I am trying to change the code to reference a particular cell value where I specify the range I want to use, but I am getting the Object Required 424 Error. I have added both lines of code the one that works well and the one that has the error.
Sub Empty_Cells()
Dim i As Long
Dim c As Long
Dim myRange As Range
Dim myCell As Range
'This line is giving me a 424 error object required
Set myRange = Worksheets("Data").Range("E1").Value
'This line of code below works well
'Set myRange = Worksheets("Data").Range("A4:H4")
For Each myCell In myRange
c = c + 1
If IsEmpty(myCell) Then
myCell = 0
i = i + 1
End If
Next myCell
MsgBox _
"There are total " & i & " empty cell(s) out of " & c & "."
'
'
End Sub
The code below allows me to add zeros to a specific row. I am trying to change the code to reference a particular cell value where I specify the range I want to use, but I am getting the Object Required 424 Error. I have added both lines of code the one that works well and the one that has the error.
Sub Empty_Cells()
Dim i As Long
Dim c As Long
Dim myRange As Range
Dim myCell As Range
'This line is giving me a 424 error object required
Set myRange = Worksheets("Data").Range("E1").Value
'This line of code below works well
'Set myRange = Worksheets("Data").Range("A4:H4")
For Each myCell In myRange
c = c + 1
If IsEmpty(myCell) Then
myCell = 0
i = i + 1
End If
Next myCell
MsgBox _
"There are total " & i & " empty cell(s) out of " & c & "."
'
'
End Sub