Jon von der Heyden
MrExcel MVP, Moderator
- Joined
- Apr 6, 2004
- Messages
- 10,912
- Office Version
- 365
- Platform
- Windows
Hi,
I suspect this code is more complicated than it needs to be. I have a series of loops doing different actions on the same column. Is there any way of condensing this?
Thanks,
Jon
I suspect this code is more complicated than it needs to be. I have a series of loops doing different actions on the same column. Is there any way of condensing this?
Code:
'Delete blank rows from Col G
For i = lastrow To 6 Step -1
Set x = Range("G" & i)
If x.Value = "" Then
x.EntireRow.Delete shift:=xlUp
End If
Next i
'---------------------------------------------------------------------------
'Delete Current Period Labels from Col G
For i = lastrow To 6 Step -1
Set x = Range("G" & i)
If x.Value = "Current Period" Then
x.EntireRow.Delete shift:=xlUp
End If
Next i
'----------------------------------------------------------------------------
'Delete Amount Labels from Col G
For i = lastrow To 6 Step -1
Set x = Range("G" & i)
If x.Value = "Amount £" Then
x.EntireRow.Delete shift:=xlUp
End If
Next i
'----------------------------------------------------------------------------
'Delete Date Labels from Col G
For i = lastrow To 6 Step -1
Set x = Range("G" & i)
If x.Value = Range("G5").Value Then
x.EntireRow.Delete shift:=xlUp
End If
Next i
Thanks,
Jon