Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help With loop macro??

Hi Everybody :-)

What i am lookin for is help\guidance with loop macro.

What i need is for the macro to run throug the data held in a number o
rows then place it in to seprate workbooks.

i.e. copies data from first row into workbook 1.xls then copies secon
row to work book 2.xls this goes on till row 8 and that row has bee
copied to 8.xls then 9th row would be copied to 1.xls etc. up unti
all the data has been placed in to seprate workbooks. (its a bit lik
one for you and one for me one for you...)

Can anybody give me any help or point me in the right direction.

Regards
Pau

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Help With loop macro??

Try a loop FOR/NEXT or WHILE/WEND using MOD and .row

It would go something like this:
--------------------------------
Sub moveData()

Dim i As Integer
Dim x As Integer
Dim mySheet As Integer
Dim mySheetRow As Integer

i = 1 'start at row 1

While Cells(i, 1) ""
x = Cells(i, 1).Row Mod 8
If x = 1 Then
mySheet = 1 'Start over every 8
mySheetRow = mySheetRow + 1 'Increment every 8
If mySheetRow = 0 Then mySheetRow = 8 'Klugy, but otherwise it
returns 0 for the 8th row.
Else
mySheet = mySheet + 1
End If
Cells(i, 2) = "Sheet " & mySheet & " row " & mySheetRow 'Demos results
in column B
'Replace the above demo assignment with something like the next line to
copy data to the other sheets
'Worksheets(mySheet + 1).Cells(mySheetRow, 1) = Cells(i, 1)
'Note that mySheet is an integer and as such will refer to the sheet
NUMBER.
'The above assumes it is sheets 2 thru 9 with sheet(1) being your data
sheet.
'You can change it to text to refer to a sheet named "1"
i = i + 1 'Increment the row counter
Wend

End Sub

'NOTES: This doesn't create sheets 1-8
' This assumes all your data is in column A of the active sheet
' This assumes your data to be copied starts in Row 1

Regards,
TH
--------------------------------
On 4/15/04 15:48, in article , "pauluk "
wrote:

Hi Everybody :-)

What i am lookin for is help\guidance with loop macro.

What i need is for the macro to run throug the data held in a number of
rows then place it in to seprate workbooks.

i.e. copies data from first row into workbook 1.xls then copies second
row to work book 2.xls this goes on till row 8 and that row has been
copied to 8.xls then 9th row would be copied to 1.xls etc. up until
all the data has been placed in to seprate workbooks. (its a bit like
one for you and one for me one for you...)

Can anybody give me any help or point me in the right direction.

Regards
Paul

---
Message posted from
http://www.ExcelForum.com/


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
Help with using a Macro Loop Mark Costello[_2_] Excel Discussion (Misc queries) 5 October 19th 07 02:01 PM
loop a macro jnjwilliams94 Excel Discussion (Misc queries) 4 August 26th 06 01:52 PM
macro loop DM Excel Discussion (Misc queries) 1 January 3rd 06 10:46 PM
Loop macro help. Pete[_13_] Excel Programming 2 November 14th 03 10:32 PM


All times are GMT +1. The time now is 12:04 PM.

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"