Need help to stop looping if next cell is empty. This is excel macro I use for copying multiple tabulation data to combine in a single data area. works but looping is not stopping.
Code:
Sub CombineToCommonColumns()
'
' CombineToCommonColumns Macro
'
'
iRow = 1
Do Until IsEmpty(Cells(iRow, 1))
'Select to column till last
Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
'Select next free cell
Dim ws As Worksheet
Set ws = ActiveSheet
For Each cell In ws.Columns(1).Cells
If Len(cell) = 0 Then cell.Select: Exit For
Next cell
'Go to right and select till last right and last down, select and cut
Range(Selection, Selection.End(xlToRight)).Select
Selection.End(xlToRight).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Cut
'Got to home
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.End(xlDown).Select
'Select next free cell
For Each cell In ws.Columns(1).Cells
If Len(cell) = 0 Then cell.Select: Exit For
Next cell
ActiveSheet.Paste
iRow = iRow + 1
Loop
End Sub
Last edited by a moderator: