Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default copy a template and fill in data from a single worksheet

I'm trying to make a macro to automate a tedious process of creating product
detail forms from a summary page.

Sheet 1 is the summary page containing data in columns A-N.The number of
rows is unlimited.

Sheet 2 is a template that would be filled in with the data from Sheet 1,
but each row in Sheet 1 would get its own individual worksheet - if I were
doing this manually, I would make as many copies of Sheet 2 as I have rows in
Sheet 1, and fill in certain cells on those sheets with the data in columns
A-N on Sheet 1. Also, the name of the worksheet would be the value in column
A.

For example, if Sheet 1 contains 10 rows of products, I would make 10 copies
of sheet 2 - the first copy would contain the data in row 1, the second copy
would contain the data in row 2, etc.

Is there a way to write a macro to automate this process?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default copy a template and fill in data from a single worksheet

try this code:


Option Explicit
'replicate sheet 'Template'
'for each row in sheet 'Main'
Sub Main()
Dim RowIndex As Long 'row counter
Dim shNew As Worksheet
Dim source As Range
RowIndex = 1
Do While Worksheets("Main").Cells(RowIndex, 1) < ""

Set shNew = Worksheets.Add(Worksheets(Worksheets.Count))
shNew.Name = "row_" & Format(RowIndex, "0000")

'copy some stuff
With Sheets("Main")
Set source = .Range(.Cells(RowIndex, "A"), .Cells(RowIndex, "N"))
End With
With source
shNew.Range("A2").Resize(.Columns.Count, 1).Value = _
WorksheetFunction.Transpose(.Value)
End With
'end of copy section
shNew.Range("a1") = "row #" & RowIndex

'next row
RowIndex = RowIndex + 1
Loop
End Sub


"Jill" wrote:

I'm trying to make a macro to automate a tedious process of creating product
detail forms from a summary page.

Sheet 1 is the summary page containing data in columns A-N.The number of
rows is unlimited.

Sheet 2 is a template that would be filled in with the data from Sheet 1,
but each row in Sheet 1 would get its own individual worksheet - if I were
doing this manually, I would make as many copies of Sheet 2 as I have rows in
Sheet 1, and fill in certain cells on those sheets with the data in columns
A-N on Sheet 1. Also, the name of the worksheet would be the value in column
A.

For example, if Sheet 1 contains 10 rows of products, I would make 10 copies
of sheet 2 - the first copy would contain the data in row 1, the second copy
would contain the data in row 2, etc.

Is there a way to write a macro to automate this process?

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
'move or copy' a single worksheet multiple times DebC Excel Discussion (Misc queries) 10 April 3rd 23 04:26 PM
Possible to copy worksheet into template? foxcole Excel Discussion (Misc queries) 3 October 2nd 07 08:47 PM
Copy Filterd Data from worksheet to another workbook template Kenny Excel Discussion (Misc queries) 1 October 2nd 07 01:13 PM
Copy Range From Multiple Worksheets to a Single Worksheet Dauntless1 Excel Discussion (Misc queries) 5 August 17th 07 01:59 AM
Copy from different workbook's worksheet into a single worksheet... [email protected] Excel Discussion (Misc queries) 1 October 27th 05 07:27 PM


All times are GMT +1. The time now is 01:37 PM.

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"