Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
Michael
 
Posts: n/a
Default Copying a worksheet into the same workbook

Hi, and thanks in advane for the help!

I would like to know how to copy an existing worksheet and automatically
rename it from a cell within that sheet into the same workbook. I have
searched but not found what I want to do. I think it has to do with the
newsheet event but not sure how to do it.

Mike
  #2   Report Post  
Posted to microsoft.public.excel.newusers
Ron de Bruin
 
Posts: n/a
Default Copying a worksheet into the same workbook

Try this for the activesheet with the sheet name in B3

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Range("B3").Value
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael" wrote in message ...
Hi, and thanks in advane for the help!

I would like to know how to copy an existing worksheet and automatically
rename it from a cell within that sheet into the same workbook. I have
searched but not found what I want to do. I think it has to do with the
newsheet event but not sure how to do it.

Mike



  #3   Report Post  
Posted to microsoft.public.excel.newusers
Michael
 
Posts: n/a
Default Copying a worksheet into the same workbook

Thanks so much Ron! It worked great!

I found that I only want to copy a range of cells into the new worksheet
because I don't want the macro buttons copied into the new sheet. Any
suggestions?

Mike

"Ron de Bruin" wrote:

Try this for the activesheet with the sheet name in B3

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Range("B3").Value
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael" wrote in message ...
Hi, and thanks in advane for the help!

I would like to know how to copy an existing worksheet and automatically
rename it from a cell within that sheet into the same workbook. I have
searched but not found what I want to do. I think it has to do with the
newsheet event but not sure how to do it.

Mike




  #4   Report Post  
Posted to microsoft.public.excel.newusers
Ron de Bruin
 
Posts: n/a
Default Copying a worksheet into the same workbook

Two ways

This also delete all shapes on the new sheet

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Range("B3").Value
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete
On Error GoTo 0
End Sub


Or copy a range into a new worksheet

Sub test2()
Dim ws1 As Worksheet
Dim ws2 As Worksheet

Set ws1 = ActiveSheet
Set ws2 = Worksheets.Add(after:=Sheets(Sheets.Count))

On Error Resume Next
ActiveSheet.Name = ws1.Range("B3").Value
On Error GoTo 0

ws1.Range("A1:G20").Copy ws2.Range("A1")

Set ws1 = Nothing
Set ws2 = Nothing

End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael" wrote in message ...
Thanks so much Ron! It worked great!

I found that I only want to copy a range of cells into the new worksheet
because I don't want the macro buttons copied into the new sheet. Any
suggestions?

Mike

"Ron de Bruin" wrote:

Try this for the activesheet with the sheet name in B3

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Range("B3").Value
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael" wrote in message ...
Hi, and thanks in advane for the help!

I would like to know how to copy an existing worksheet and automatically
rename it from a cell within that sheet into the same workbook. I have
searched but not found what I want to do. I think it has to do with the
newsheet event but not sure how to do it.

Mike






  #5   Report Post  
Posted to microsoft.public.excel.newusers
Ron de Bruin
 
Posts: n/a
Default Copying a worksheet into the same workbook

ActiveSheet.Name = ws1.Range("B3").Value

Use this instead

ws2.Name = ws1.Range("B3").Value


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron de Bruin" wrote in message ...
Two ways

This also delete all shapes on the new sheet

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Range("B3").Value
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete
On Error GoTo 0
End Sub


Or copy a range into a new worksheet

Sub test2()
Dim ws1 As Worksheet
Dim ws2 As Worksheet

Set ws1 = ActiveSheet
Set ws2 = Worksheets.Add(after:=Sheets(Sheets.Count))

On Error Resume Next
ActiveSheet.Name = ws1.Range("B3").Value
On Error GoTo 0

ws1.Range("A1:G20").Copy ws2.Range("A1")

Set ws1 = Nothing
Set ws2 = Nothing

End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael" wrote in message ...
Thanks so much Ron! It worked great!

I found that I only want to copy a range of cells into the new worksheet
because I don't want the macro buttons copied into the new sheet. Any
suggestions?

Mike

"Ron de Bruin" wrote:

Try this for the activesheet with the sheet name in B3

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Range("B3").Value
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael" wrote in message ...
Hi, and thanks in advane for the help!

I would like to know how to copy an existing worksheet and automatically
rename it from a cell within that sheet into the same workbook. I have
searched but not found what I want to do. I think it has to do with the
newsheet event but not sure how to do it.

Mike









  #6   Report Post  
Posted to microsoft.public.excel.newusers
Michael
 
Posts: n/a
Default Copying a worksheet into the same workbook

All has worked great so far, many thanks.

One last question (I hope): How do I get the new sheet not to display the
gridlines automatically? The sheet it is copied from has the gridlines
turned off.

Mike

"Ron de Bruin" wrote:

ActiveSheet.Name = ws1.Range("B3").Value


Use this instead

ws2.Name = ws1.Range("B3").Value


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ron de Bruin" wrote in message ...
Two ways

This also delete all shapes on the new sheet

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Range("B3").Value
ActiveSheet.DrawingObjects.Visible = True
ActiveSheet.DrawingObjects.Delete
On Error GoTo 0
End Sub


Or copy a range into a new worksheet

Sub test2()
Dim ws1 As Worksheet
Dim ws2 As Worksheet

Set ws1 = ActiveSheet
Set ws2 = Worksheets.Add(after:=Sheets(Sheets.Count))

On Error Resume Next
ActiveSheet.Name = ws1.Range("B3").Value
On Error GoTo 0

ws1.Range("A1:G20").Copy ws2.Range("A1")

Set ws1 = Nothing
Set ws2 = Nothing

End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael" wrote in message ...
Thanks so much Ron! It worked great!

I found that I only want to copy a range of cells into the new worksheet
because I don't want the macro buttons copied into the new sheet. Any
suggestions?

Mike

"Ron de Bruin" wrote:

Try this for the activesheet with the sheet name in B3

Sub test()
ActiveSheet.Copy after:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = Range("B3").Value
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Michael" wrote in message ...
Hi, and thanks in advane for the help!

I would like to know how to copy an existing worksheet and automatically
rename it from a cell within that sheet into the same workbook. I have
searched but not found what I want to do. I think it has to do with the
newsheet event but not sure how to do it.

Mike








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
Macro or OLE method to insert worksheet from template workbook Lyndon Rickards Excel Discussion (Misc queries) 0 January 30th 06 08:46 PM
Protect Workbook vs Worksheet?? Dan B Excel Worksheet Functions 3 November 7th 05 09:02 PM
sort worksheet without affecting workbook Barry Excel Worksheet Functions 3 November 2nd 05 10:06 PM
Linking cells in a worksheet to other worksheets in a workbook Dave Excel Discussion (Misc queries) 4 June 24th 05 06:18 PM
Error Copying Worksheet Steve King Excel Worksheet Functions 1 April 13th 05 09:49 PM


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