Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Increasing the Sheet #

Hi all,

I have an Excel sheet that links to Access database. I have created a macro
to copy the entire linked sheet and to turn the copied sheet into value.

One of my macro lines is to rename the copied sheet into "Workable Schedule
1". Here is the line:

Sheets("Linked Sheet (2)").Name = "Workable Schedule 1"

What I like to do is to make the macro to increment each copied sheet by 1
when I click on the command button on the linked sheet. For example,
"Workable Schedule 1", "Workable Schedule 2", etc.

Please help.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Increasing the Sheet #

Hi,

Try this:

Sub InsertRenameSheet()
Dim NewSheet As Worksheet, n As Integer
Sheets("Linked Sheet").Copy after:=Sheets(Sheets.Count)
Set NewSheet = Sheets(Sheets.Count)
n = 1
On Error Resume Next
Do
Err.Clear
NewSheet.Name = "Workable Schedule " & n
n = n + 1
Loop While Err.Number 0
On Error GoTo 0
End Sub

Note that if one of the copied sheet is deleted the number will be re-used
at the next run.

Regards,

Manu/

"Please Help" a écrit dans le message
de news: ...
Hi all,

I have an Excel sheet that links to Access database. I have created a
macro
to copy the entire linked sheet and to turn the copied sheet into value.

One of my macro lines is to rename the copied sheet into "Workable
Schedule
1". Here is the line:

Sheets("Linked Sheet (2)").Name = "Workable Schedule 1"

What I like to do is to make the macro to increment each copied sheet by 1
when I click on the command button on the linked sheet. For example,
"Workable Schedule 1", "Workable Schedule 2", etc.

Please help.

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Increasing the Sheet #

Good morning Manu,

Thanks for your help. Your code works perfectly. Thanks again.

"tissot.emmanuel" wrote:

Hi,

Try this:

Sub InsertRenameSheet()
Dim NewSheet As Worksheet, n As Integer
Sheets("Linked Sheet").Copy after:=Sheets(Sheets.Count)
Set NewSheet = Sheets(Sheets.Count)
n = 1
On Error Resume Next
Do
Err.Clear
NewSheet.Name = "Workable Schedule " & n
n = n + 1
Loop While Err.Number 0
On Error GoTo 0
End Sub

Note that if one of the copied sheet is deleted the number will be re-used
at the next run.

Regards,

Manu/

"Please Help" a écrit dans le message
de news: ...
Hi all,

I have an Excel sheet that links to Access database. I have created a
macro
to copy the entire linked sheet and to turn the copied sheet into value.

One of my macro lines is to rename the copied sheet into "Workable
Schedule
1". Here is the line:

Sheets("Linked Sheet (2)").Name = "Workable Schedule 1"

What I like to do is to make the macro to increment each copied sheet by 1
when I click on the command button on the linked sheet. For example,
"Workable Schedule 1", "Workable Schedule 2", etc.

Please help.

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
Increasing font? lon8384 Excel Worksheet Functions 2 April 4th 07 01:03 PM
Autofill with sheet number increasing Jamo Excel Discussion (Misc queries) 0 May 15th 06 11:22 PM
Increasing Sheet Numbers by one on fill down command albertmb Excel Worksheet Functions 1 March 12th 06 08:41 AM
Increasing M in M/D/Y Bill45 Excel Discussion (Misc queries) 2 May 19th 05 06:32 PM
How do I print the same sheet multiple times with increasing page. C&S Excel Discussion (Misc queries) 4 March 31st 05 09:21 AM


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