Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing #Null! with zero 1

Status
Not open for further replies.

Lightning

Technical User
Jun 24, 2000
1,140
AU
I have a worksheet with some numerical data imported from a .txt file. Because some of this data is Null, I am getting a number of cells that contain "#NULL!". I need to convert these cells to 0 using VBA, but I'm not having much success. Could somebody tell me what is wrong with my code below.

Code:
    Do While (Not IsEmpty(CurrentCell))
        Set NextCell = CurrentCell.Offset(1, 0)
        If CurrentCell = (Error.Type(1)) Then
            CurrentCell.Value = 0
        End If
        Set CurrentCell = NextCell
    Loop

Error.Type(1) should identify the #Null! error, according to the on-line help. However, whenever I run the code I get an error message 424 - "Object Required"

What am I doing wrong?

Thanks in advance

Lightning


 
try this:
Cells.Replace What:="#NULL!", Replacement:=0, LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False

ide
 
Thanks

That did exactly what I wanted

Lightning
X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top