How do I stop this macro?
The macro below transposes data in a variable sized table on a worksheet so
in this case the macro would add 67, 28 and 37 to the top row, 47 and 89 to
the second row and 58 to the third row.
100
67 100
28 47 100
37 89 58 100
My problem is it doesn't stop when the macro reaches the cell in the bottom
right corner of the range.
You'll see I've tried to use a Do Loop solution which I've placed in various
sections of the code without success.
-------------------------
Sub TranposeData()
Dim lastrow As Long
Dim R As Long, C As Integer
Dim rng As Range
ActiveCell.Offset(1, 1).Activate
Set rng = ActiveCell
lastrow = ActiveCell.End(xlDown).Row + 1
Do Until ActiveCell.Offset(1, 1) = Empty
For R = rng(1).Row To lastrow
C = Cells(R, Columns.Count).End(xlToLeft).Column
Range(Cells(R + 1, C), Cells(lastrow - 1, C)).Copy
Cells(R, C + 1).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone,
SkipBlanks:=False, Transpose:=True
Next R
Loop
Application.CutCopyMode = False
End Sub
----------
I'd be grateful for some help on how to make this run correctly.
Thanks a lot
|