Find and Replace Macro

SammieH

New Member
Joined
Mar 11, 2019
Messages
2
Hi all,

I'm very new to macros so I feel like this is pretty simple, but I just cant get there yet.

I have a very large file downloaded to Excel from SPSS. SPSS left behind a lot of #NULL ! in my spreadsheet.
Doing a simple CTRL+F and Replace will crash Excel because the file is so large.

I want to do this in a macro. I want it to search the entire spreadsheet and replace #NULL ! with "" (a blank cell).

<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px 'Helvetica Neue'; color: #000000 ; color: rgba(0, 0, 0, 0.85)}</style>I tried and got the following error:

Invalid outside procedure

This is the code I tried:

Sub RemoveNull()
'
' RemoveNull Macro
' Remove #NULL ! from SPSS Export
'


'
Cells.Select
Selection.Replace What:="#NULL !", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub

Thanks!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Sammie,

Try this procedure (it will take some time to execute for a large spreadsheet however)
Code:
Sub ReplaceNulls()
    Dim rng As Range
    Dim cell As Range
    
    Application.ScreenUpdating = False
    
    Set rng = Selection
    For Each cell In rng
        If cell.Value = "#NULL !" Then
            cell.Value = ""
        End If
    Next cell
End Sub
 
Upvote 0
Hi SammieH,

this will erase every error from the sheet:
Code:
Sub SammieH_ErrorCleanUp()
Cells.Select
For Each cell In Selection
If IsError(cell.Value) Then cell.Value = ""
Next cell
End Sub

Good luck
 
Upvote 0
How about
Code:
Sub SammieH()
   Cells.SpecialCells(xlConstants, xlErrors).Value = ""
End Sub
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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