LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to stop at a certain tab and does not go to the next one. [email protected] Excel Worksheet Functions 3 March 16th 06 01:11 AM
How do I stop a macro from running within a macro? JohnUK Excel Programming 1 June 26th 05 10:59 AM
Stop running a macro in the middle of a macro gmunro Excel Programming 3 June 9th 05 06:00 PM
Macro: With Stop it works. Without Stop it doesn't. Don Wiss Excel Programming 2 October 12th 04 10:49 AM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 02:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"