Hi
Anyone able to help me debug my code below? it kept prompting me compile error: else without if
where did i make a mistake?
Dim s As String
Dim r As Long
Dim c As Long
'set active sheet
Set ws = ActiveSheet
'finds the last row
lstrow = ws.UsedRange.Rows.Count
c = 2
For r = 1 To lstrow
If Cells(r, c) = "" Then Cells(r, c) = Cells(r, c - 1)
Else
Cells(r, c) = Cells(r - 1, c)
End If
Next r
End Sub
Anyone able to help me debug my code below? it kept prompting me compile error: else without if
where did i make a mistake?
Dim s As String
Dim r As Long
Dim c As Long
'set active sheet
Set ws = ActiveSheet
'finds the last row
lstrow = ws.UsedRange.Rows.Count
c = 2
For r = 1 To lstrow
If Cells(r, c) = "" Then Cells(r, c) = Cells(r, c - 1)
Else
Cells(r, c) = Cells(r - 1, c)
End If
Next r
End Sub