Invalid or unqualified reference

MrHawkins88

New Member
Joined
Feb 4, 2010
Messages
47
Hello,

When I run this code I get a compile error that says "Invalid or unqualified reference" when I looked into it the error seems to be saying that I am not using a With statement properly. But I am not using a with statement at all.

Has anyone got any suggestions?

Code:
Sub deletingdata()
 
Dim i           As Integer
Dim j           As Integer
Dim WS          As Worksheet
Dim toprow      As Range
Dim lastrow     As Range
Dim AFcolumn    As Range
 
i = 0
For Each WS In Worksheets
    i = i + 1
    Sheets(WS.Name).Activate
    
    If i <> 1 Then
    
        Range("D:D").Cells.Replace What:="nan", Replacement:="", LookAt:=xlPart, SearchOrder _
            :=xlByColumns, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
        
        On Error Resume Next
        Columns("D:D").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
        ActiveSheet.UsedRange
        Set toprow = .Find(What:="ActiveFaults", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, _
                            SearchDirection:=xlNext, MatchCase:=False).Offset(0, 3).Row
                        
        Set AFcolumn = .Find(What:="ActiveFaults", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, _
                            SearchDirection:=xlNext, MatchCase:=False).Column
                        
        lastrow = Range("AFCol & 65536").End(xlUp).Row
        For j = lastrow To toprow Step -1
        If Cells(j, AFcolumn).Value <> "00*555" Then Cells(j, o).Delete shift:=xlUp
        Next j
        
    End If
    
End Sub

Thanks in advance!
 
No I didn't - hence the question (mark). The error message indicated an unqualified reference and that was the obvious one.

Hopefully with your code the OP is well on his way to a fix.
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,221,831
Messages
6,162,248
Members
451,756
Latest member
tommyw

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