AKK
06-23-2009, 11:32 AM
Hi,
I am running the following VBA code on Excel:
Sub FindNewlyClosed()
Dim iRowCount As Integer, iCounter As Integer
Range("H2").Value = ActiveSheet.UsedRange.Rows.Count
Range("B2").Select
If Selection.Value = Selection.Offset(0, -1) Then Range("B3").Select
Else: Range("A2").Select
Selection.Insert Shift:=xlDown
Range("B5").Select
Selection.Font.ColorIndex = 41
Selection.Font.Bold = True
End Sub
When I try to run it, I get an error message that says "Else without If." I don't understand why I'm getting this error since the 'If' is in the line right above it. Can anyone help?
Thanks!
I am running the following VBA code on Excel:
Sub FindNewlyClosed()
Dim iRowCount As Integer, iCounter As Integer
Range("H2").Value = ActiveSheet.UsedRange.Rows.Count
Range("B2").Select
If Selection.Value = Selection.Offset(0, -1) Then Range("B3").Select
Else: Range("A2").Select
Selection.Insert Shift:=xlDown
Range("B5").Select
Selection.Font.ColorIndex = 41
Selection.Font.Bold = True
End Sub
When I try to run it, I get an error message that says "Else without If." I don't understand why I'm getting this error since the 'If' is in the line right above it. Can anyone help?
Thanks!