#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default repeating macro

I would like to repeat a macro until no data is found.

I am pulling data from a column and transposing the data into rows. The
data repeats after ten rows and than I have to start a new row to transpose.
I have created a macro that transposes the data, but I want to repeat the
macro until no other data is found. Any advice would be appreciated.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,203
Default repeating macro

Try this one, adjust the Const values as required. As written, it will take
the information in column A and move it in groups of 10 using columns C:L
beginning at row 2.

Sub TransposeColumnToRows()
'column the source information to be
'transposed is in
Const sourceCol = "A"
'first row with a data item to be
'transposed
Const firstDataRow = 1
'the size of the groups to be
'transposed
Const groupSize = 10
'the first column to use for
'transposing the data
Const newCol = "C"

Dim lastRow As Long
Dim RC As Long
Dim CC As Integer
Dim rowPointer As Integer

lastRow = Range(sourceCol & Rows.Count).End(xlUp).Row
For RC = firstDataRow To lastRow Step groupSize
rowPointer = Range(newCol & Rows.Count).End(xlUp).Row + 1
For CC = 0 To groupSize - 1
Range(newCol & rowPointer).Offset(0, CC) = _
Range(sourceCol & RC).Offset(CC, 0)
Next
Next
End Sub

To put the code to work, open the workbook, press [Alt]+[F11] to open the VB
Editor and choose Insert -- Module. Copy the code and paste it into the
module and make any changes you need to. Close the VB Editor. Select the
sheet with the data to transpose and use Tools -- Macro -- Macros to run
the code.

"dwake" wrote:

I would like to repeat a macro until no data is found.

I am pulling data from a column and transposing the data into rows. The
data repeats after ten rows and than I have to start a new row to transpose.
I have created a macro that transposes the data, but I want to repeat the
macro until no other data is found. Any advice would be appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default repeating macro

Worked perfect....much abliged.

"JLatham" wrote:

Try this one, adjust the Const values as required. As written, it will take
the information in column A and move it in groups of 10 using columns C:L
beginning at row 2.

Sub TransposeColumnToRows()
'column the source information to be
'transposed is in
Const sourceCol = "A"
'first row with a data item to be
'transposed
Const firstDataRow = 1
'the size of the groups to be
'transposed
Const groupSize = 10
'the first column to use for
'transposing the data
Const newCol = "C"

Dim lastRow As Long
Dim RC As Long
Dim CC As Integer
Dim rowPointer As Integer

lastRow = Range(sourceCol & Rows.Count).End(xlUp).Row
For RC = firstDataRow To lastRow Step groupSize
rowPointer = Range(newCol & Rows.Count).End(xlUp).Row + 1
For CC = 0 To groupSize - 1
Range(newCol & rowPointer).Offset(0, CC) = _
Range(sourceCol & RC).Offset(CC, 0)
Next
Next
End Sub

To put the code to work, open the workbook, press [Alt]+[F11] to open the VB
Editor and choose Insert -- Module. Copy the code and paste it into the
module and make any changes you need to. Close the VB Editor. Select the
sheet with the data to transpose and use Tools -- Macro -- Macros to run
the code.

"dwake" wrote:

I would like to repeat a macro until no data is found.

I am pulling data from a column and transposing the data into rows. The
data repeats after ten rows and than I have to start a new row to transpose.
I have created a macro that transposes the data, but I want to repeat the
macro until no other data is found. Any advice would be appreciated.


Reply
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 repeating getting the data ivy Excel Discussion (Misc queries) 1 November 19th 08 02:29 AM
repeating a macro tylermdsm Excel Discussion (Misc queries) 1 January 31st 08 11:20 PM
Repeating a Macro Based Carl Excel Worksheet Functions 2 September 2nd 06 05:15 PM
Repeating Macro Dino Excel Discussion (Misc queries) 3 February 15th 06 03:58 AM
Repeating a Macro For Each Selected Worksheet carl Excel Worksheet Functions 0 January 11th 06 10:07 PM


All times are GMT +1. The time now is 10:08 AM.

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

About Us

"It's about Microsoft Excel"