Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default New worksheet button code

Hi,

I need to be able to create a button, that when pressed will copy the
current worksheet into a new worksheet. The first worksheet is to be
called 'Report1', the next worksheet needs to be called 'Report2' and
so on. I have adpated some code I have access to and so far have the
following:

Sub Button135_Click()
Dim strSheetName As String

strSheetName = InputBox("Enter sheet name")
Sheets("Report1").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = strSheetName

End Sub

I want to get rid of the Input box asking for the name of the
worksheet and automate this so that it goes Report1, Report2,
Report3........

Is this possible?

Also, on the newly created sheets some of the fields need to be a
running total from the sheet previous. Hoew can I get these to update?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default New worksheet button code

This will automatically number your reports, based on the number of sheets
in the workbook. If you have three sheets when you click the button, the
report number would be four. You can manage the report number by
subtracting or adding to Sheets.Count.

Sheets(Sheets.Count).Name = "Report" & Sheets.Count - 2

would number the report at two less than the number of sheets, etc.


Sub Button135_Click()
Dim strSheetName As String
Sheets("Report1").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "Report" & Sheets.Count
End Sub


I don't understand the other part of your post.


"Gary" wrote in message
...
Hi,

I need to be able to create a button, that when pressed will copy the
current worksheet into a new worksheet. The first worksheet is to be
called 'Report1', the next worksheet needs to be called 'Report2' and
so on. I have adpated some code I have access to and so far have the
following:

Sub Button135_Click()
Dim strSheetName As String

strSheetName = InputBox("Enter sheet name")
Sheets("Report1").Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = strSheetName

End Sub

I want to get rid of the Input box asking for the name of the
worksheet and automate this so that it goes Report1, Report2,
Report3........

Is this possible?

Also, on the newly created sheets some of the fields need to be a
running total from the sheet previous. Hoew can I get these to update?

Thanks.



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 to add button w/code to new worksheet PJ Excel Programming 2 February 18th 09 05:25 PM
Enable or Disable Forms Button on a worksheet from code Corey Excel Programming 1 November 5th 07 12:43 AM
Command button to toggle worksheet event code on / off? Fred[_2_] Excel Discussion (Misc queries) 15 July 31st 07 11:50 AM
How do I code VBA to hit button on a different worksheet? [email protected] Excel Programming 5 August 8th 06 09:39 PM
c# code to add button control to the worksheet!!!! .NetProf Excel Programming 0 January 30th 06 04:45 AM


All times are GMT +1. The time now is 05:04 AM.

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"