blondie7228
New Member
- Joined
- Feb 23, 2012
- Messages
- 3
I am trying to delete all rows until the macro reaches the row that contains "Loan Detail" in column A. I am using the following code, it seems to find the row but deletes it. I want it to delete UNTIL reaching that row.
Any input?
Sub DeleteRow()
Dim F
Dim MyValue
MyValue = "Loan Detail"
With Cells Set F = .Find(What:=MyValue, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If ((Not F Is Nothing) And (F.Row <> 1)) Then
Range(Range("A1"), Cells(F.Row - 1, 1)).EntireRow.Delete
If (F.Column <> 1) Then
Range(Range("A1"), Cells(1, F.Column - 1)).EntireColumn.Delete
End If
End If
End With
ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
Any input?
Sub DeleteRow()
Dim F
Dim MyValue
MyValue = "Loan Detail"
With Cells Set F = .Find(What:=MyValue, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False)
If ((Not F Is Nothing) And (F.Row <> 1)) Then
Range(Range("A1"), Cells(F.Row - 1, 1)).EntireRow.Delete
If (F.Column <> 1) Then
Range(Range("A1"), Cells(1, F.Column - 1)).EntireColumn.Delete
End If
End If
End With
ActiveSheet.UsedRange.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
Last edited: