There are a couple things you could do to improve this.
1. Declare all your variables. For instance, iCol is not declared as anything so if you want it to be of a Long variable you should declare it as such. Hence, your Dim line should look something like:
Dim iRow As Long, iCol As Long, iTargetRow As Long, iMaxRow As Longl
2. Declare the worksheet like:
Dim Ws As Worksheet
Set Ws = ActiveSheet
Your procedure could look something like:
Option Explicit
Sub Stack()
Dim Ws As Worksheet
Dim iRow As Long, iCol As Long, iTargetRow As Long, iMaxRow As Long
Set Ws = ActiveSheet
iMaxRow = 10000
iTargetRow = 4
Ws.Columns(55).Clear
For iCol = 39 To 43
For iRow = 4 To iMaxRow
If Ws.Cells(iRow, iCol) > "" Then
Ws.Cells(iTargetRow, 55) = Ws.Cells(iRow, iCol)
iTargetRow = iTargetRow + 1
Else: Exit For
End If
Next iRow
Next iCol
End Sub
Let me know how it goes.
Bookmarks