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

E

I forgot to rename the sheet. See code below for change



Sub MakeSheets()

Dim cell As Range
Dim Rng As Range
Dim wsh As Worksheet

Set Rng = Sheet1.Range("a2", Sheet1.Range("A2").End(xlDown))

'Loop through cells
For Each cell In Rng.Cells

'Create new sheet
Set wsh = ThisWorkbook.Worksheets.Add(, _
ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))

'Copy header row
cell.Offset(-cell.Row + 1, 0).Resize(, 7).Copy _
wsh.Range("a1")

'Copy data row
cell.Resize(, 7).Copy _
wsh.Range("A65536").End(xlUp).Offset(1, 0)


On Error Resume Next
wsh.Name = wsh.Range("A2").Value
On Error Goto 0

Next cell


End Sub


--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.




 
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 05:30 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"