I have a macro to delete blank cells in each row and shift the next cell to the left. The code is not showing any errors, but does nothing.
As the number of columns can vary from row to row, I have defined the last row inside the For Each loop.
Help with correction gratefully received.
Sub RemoveBlankCells()
Dim rng As Range
Dim row As Range
Dim cell As Range
Dim lastCol As Long
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("ABC")
For Each row In ws.Rows
lastCol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
Set rng = ws.Cells(1, lastCol)
For Each cell In rng.Cells
If cell.Value = "" Then
cell.Delete Shift:=xlToLeft
End If
Next cell
Next row
End Sub