Dim MaxTemp As Long
Sub UpdateColumnA()
Dim ws As Worksheet
Dim lastRow As Long, lastCol As Long
Dim i As Long, j As Long
Set ws = ThisWorkbook.Sheets("Sheet1")
lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).row
lastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
Call FindLastRowInColumns
For i = 2 To MaxTemp
For j = lastCol To 2 Step -1
If Not IsEmpty(ws.Cells(i, j)) Then
ws.Cells(i, 1).Value = ws.Cells(1, j).Value
Exit For
End If
Next j
Next i
End Sub
Sub FindLastRowInColumns()
Dim ws As Worksheet
Dim lastColumn As Long
Dim i As Long, lastRow As Long, maxRow As Long
Set ws = ThisWorkbook.Sheets("Sheet1")
lastColumn = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
maxRow = 0
For i = 1 To lastColumn
lastRow = ws.Cells(ws.Rows.Count, i).End(xlUp).row
If lastRow > maxRow Then
maxRow = lastRow
End If
Next i
MaxTemp = maxRow
End Sub