Your technology certification is waiting. Enroll in Cloud Class ®
Dim ShArr, Sh
Dim dws As Worksheet, ws As Worksheet
Dim lr As Long, lc As Long, i As Long, dlc As Long
Application.ScreenUpdating = False
Set dws = Sheets("Sheet5")
ShArr = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")
For Each Sh In ShArr
Set ws = Sheets(Sh)
lr = ws.Cells(Rows.Count, 1).End(xlUp).Row
If dws.Range("A1").Value = "" Then ws.Range("A2:A" & lr).Copy dws.Range("A1")
For i = 2 To lr
lc = ws.Cells(i, Columns.Count).End(xlToLeft).Column
If lc > 1 Then
dlc = dws.Cells(i - 1, Columns.Count).End(xlToLeft).Column + 1
ws.Range("B" & i, ws.Cells(i, lc)).Copy dws.Cells(i - 1, dlc)
Application.ScreenUpdating = True
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.