I have the following code that iterates through columns and copies the columns to another spreadsheet.
Whenever a column is empty the column label gets copied to the new sheet even though the codes stops
right below the label? The labels are in row 6 in the sheet I am copying from.
[codebox]
Set WshTarget = ThisWorkbook.Worksheets(“9and3”)
WshTarget.Range(“A5:AJ3000”).Clear
With WshSource
For Lngcol = 2 To 14
n = WshSource.Cells(WshSource.Rows.Count, Lngcol).End(xlUp).Row
WshSource.Range(.Cells(7, Lngcol), .Cells(n, Lngcol)).Copy _
Destination:=WshTarget.Cells(5, Lngcol – 1)
Application.CutCopyMode = False
Next Lngcol
End With
[/codebox]