0

I need to create vba code which will delete a set of ranges and shift cells left IF a certain cell is blank on a row (the range needs to only be deleted for the row with the blank cell). So if TV4 is blank, it needs to delete the respective ranges specified only for the 4th row.

I've created the following code but am running into multiple errors, any help is thoroughly appreciated:

Sub Deleteblanks()

' Deleteblanks Macro

    Dim i As Long

    For i = 2 To 999999
    
        If IsEmpty(Range("TV" & i)) Then
        Range("TV" & i : "AUB" & i).Select
        Selection.Delete Shift:=xlToLeft
        
        Range("AOO"&i:"BOU"&i).Select
        Selection.Delete Shift:=xlToLeft
        
        Range("BJH"&i:"CJN"&i").Select
        Selection.Delete Shift:=xlToLeft
        
        End If
        
    Next i
    
    Range("A1").Select
    
End Sub
IJUT
  • 1
  • 1
  • 2
    `"TV" & i & ":AUB" & i` and so on. The `:` belongs inside the quotes, and you're missing an `&`. – BigBen May 30 '23 at 13:34
  • Recommended reading: [How to avoid using Select](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba) – BigBen May 30 '23 at 13:34

0 Answers0