Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Swenk,
Thanks for the quick reply. I follow what you're saying and I will use your code to name the worksheets; however, I still don't know how to integrate the looping code of the second macro into the copy code of the first macro. Perhaps I didn't explain it well enough: The first macro copies a range to a new worksheet and names the worksheet according to the value in A1. It does not loop at all: Sub CopyRange() Dim ws As Worksheet, ws1 As Worksheet, c As Range Set ws = ActiveSheet Set c = ActiveCell Set ws1 = Sheets.Add ws.Range("A2:G2").Copy ws1.Range("A1") ws1.Name = ws1.Range("A1") ws.Select c.Select End Sub This macro "loops" by going through a list and creating new sheets until the list is finished (please note that the two macros are from different sources and thus have different "dim" definitions: Sub nameSheetsFromSheet() Dim vNames() As Variant Dim Cntr As Long Dim wbNew As Worksheet vNames() = Worksheets("Setup").Range("A2:A" & Worksheets("Setup") _ Range("B65536").End(xlUp).Row).Value For Cntr = 1 To UBound(vNames()) Set wbNew = ThisWorkbook.Worksheets.Add wbNew.Name = vNames(Cntr, 1) Set wbNew = Nothing Next Cntr End Sub What I need is a macro that copies a range to a new worksheet AND repeats this step until all of the elements in the list have been copied to new worksheets. I can follow the logic of the first macro and the macro that you sent, but I have no clue on the looping code in the second macro. Could you help me to combine them? Thanks a lot! E. Kohl *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro Copy Worksheet Name into worksheet A1 | Excel Worksheet Functions | |||
VB Macro to Copy from Worksheet | Excel Discussion (Misc queries) | |||
Macro to copy worksheet | Excel Discussion (Misc queries) | |||
I need help with a macro which will copy a worksheet and.. | Excel Worksheet Functions | |||
Copy from worksheet to worksheet with Macro | Excel Programming |