I have a macro to extract data from sheet "current Data" to sheet "New Account numbers Added"
Sub Extract_Newaccount_Numbers()
With Sheets("New Account numbers Added")
Dim lr As Long
lr = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A1:F" & lr).ClearContents
.Range("A1:F1").Interior.ColorIndex = xlNone
End With
With Sheets("New Account numbers Added")
Sheets("Current Data").Columns("A:F").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("Criteria"), CopyToRange:=Range("A1"), Unique:=False
.Range("A:F").EntireColumn.AutoFit
End With
End Sub
the above code runs perfectly and extract the data
However, If the range F2 to the last row in Col F is blank, then I would like the Macro to exit
I have tried to write code to get this to work, but get a compile error: "Else without if
See additional code below to exit sub if F2 to last row in col f is blank
Sub Extract_Newaccount_Numbers()
With Sheets("New Account numbers Added")
Dim lr As Long
lr = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A1:F" & lr).ClearContents
.Range("A1:F1").Interior.ColorIndex = xlNone
End With
With Sheets("Current Data")
Dim LR1 As Long
LR1 = .Range("A" & .Rows.Count).End(xlUp).Row
If Range("f2:F" & LR1).Value = "" Then Exit Sub
Else
End If
End With
With Sheets("New Account numbers Added")
Sheets("current data").Columns("A:F").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("Criteria"), CopyToRange:=Range("A1"), Unique:=False
.Range("A:F").EntireColumn.AutoFit
End With
End Sub
your assistance in resolving this is most appreciated
Bookmarks