Im trying to define a macro to help me remove unwanted rows based on some predefined conditions in each column. From the below example im deleting all the rows other than those rows in column B which has the value Y. Having done that, from Column C i want to delete all those rows other than those has value "Bank" and if there isn't data available after running this script i basically want my macro to Stop running further. I have the below code defined but it gives me the error "Block If without End If". I tried all the possible ways to debug this error but i failed :-(
Appreciate if someone can help me being new to macros..
Sheets("Sheet1").Select
Range("B2").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value <> "Y" Then
Selection.EntireRow.Delete
Else: ActiveCell.Offset(1, 0).Select
End If
Loop
If Sheets("Sheet1").Range("B2") = 0 Then
'Do Nothing
Else
Range("C2").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value <> "Corp" Then
Selection.EntireRow.Delete
Else: ActiveCell.Offset(1, 0).Select
End If
Loop
If Sheets("Sheet1").Range("c2") = 0 Then
'Do Nothing
Else
Range("D2").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value <> "Loan" Then
Selection.EntireRow.Delete
Else: ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub
Appreciate if someone can help me being new to macros..
Sheets("Sheet1").Select
Range("B2").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value <> "Y" Then
Selection.EntireRow.Delete
Else: ActiveCell.Offset(1, 0).Select
End If
Loop
If Sheets("Sheet1").Range("B2") = 0 Then
'Do Nothing
Else
Range("C2").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value <> "Corp" Then
Selection.EntireRow.Delete
Else: ActiveCell.Offset(1, 0).Select
End If
Loop
If Sheets("Sheet1").Range("c2") = 0 Then
'Do Nothing
Else
Range("D2").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value <> "Loan" Then
Selection.EntireRow.Delete
Else: ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub