LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How? Macro to copy range to new worksheet, name new worksheet, loop

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
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 Copy Worksheet Name into worksheet A1 bmac Excel Worksheet Functions 3 October 4th 07 07:51 PM
VB Macro to Copy from Worksheet KCG Excel Discussion (Misc queries) 1 September 2nd 07 08:46 AM
Macro to copy worksheet clarknv Excel Discussion (Misc queries) 2 June 17th 07 08:42 PM
I need help with a macro which will copy a worksheet and.. Greegan Excel Worksheet Functions 2 July 29th 05 11:48 PM
Copy from worksheet to worksheet with Macro Robert L. Altic Jr. Excel Programming 6 September 13th 03 10:40 PM


All times are GMT +1. The time now is 06:07 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"