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?
Thanks in advance!
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!