Object variable error

O

Oreg

Hello,

Using a macro to delete rows depending on blank cells in column A. A
times,all cells in column A are blank and macro fails. Object variabl
not set error when this occurs. Is there an error statement I ca
insert to overcome this problem? Something like on error resume nex
?

Thanks !

Sub DeleteRowsThatLookEmptyinColA()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual 'pre XL97 xlManual
Dim Rng As Range, ix As Long
Set Rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For ix = Rng.Count To 1 Step -1
If Trim(Replace(Rng.Item(ix).Text, Chr(160), Chr(32))) = "" Then
Rng.Item(ix).EntireRow.Delete
End If
Next
done:
Application.Calculation = xlCalculationAutomatic
End Su
 
G

Guest

Have you tried this:
Set Rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
If Not (Rng is Nothing) Then...
For ix = Rng.Count To 1 Step -1
If Trim(Replace(Rng.Item(ix).Text, Chr(160), Chr(32))) = "" Then
Rng.Item(ix).EntireRow.Delete
End If
Next
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top