faster way to changing Sheet tab name

ianccy

Active Member
Joined
Jul 28, 2002
Messages
332
I want to change the Sheet name according to a column of data pasted to some cells,

I will paste the data to Sheet1 A1:A200, Sheet2 will be named "A1" , Sheet3 will be named "A2", and the rest of the sheets will be added and named,

How to do this,

Thanks for any help
 
Last edited:
for example, sheet 3 named “103.Room", it has some codes like this,


Sub Refreshw_103_Room()
'---------------------------
'Macros Room_maintenance
' 103.Room - Weekly
'---------------------------

MyAdress = "A1"
KolDN = 5169
MyFixedFloat = 1
Period = "w"
.
.
.
.
LockChanged = "103.Room"
MyRange = "A1:F180"
MyNaprav = 1
.
.
.
.
Public Sub RefreshSheet()

Call Refreshw_103_Room

End Sub


when add the new sheet "104.Room" after Sheet3, sheet4 should also include the codes


Sub Refreshw_104_Room()
'---------------------------
'Macros Room_maintenance
' 104.Room - Weekly
'---------------------------

MyAdress = "A1"
KolDN = 5169
MyFixedFloat = 1
Period = "w"
.
.
.
.
LockChanged = "104.Room"
MyRange = "A1:F180"
MyNaprav = 1
.
.
.
.
Public Sub RefreshSheet()

Call Refreshw_104_Room

End Sub



where the "103" number in the codes in sheet3 is now changed to "104" in Sheet4 (as relative to the Sheet4 name "104"),

I have many sheets else i have to edit them for a long time, anyway I can quickly change it?
 
Last edited:
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I am not sure can you copy the Code to the other sheets. You can make the copy of Sheet3 and then change the sheet name of this copy but it will have the exactly same code. you can of course make it work, but you need to change code in the sheet so it will use variable which base on the sheet name (and do changes in it like replace "." with "_") instead of manual declare this variable.

Let me know if this make sens.
If not then better create new thread as this request is not related to what was requested in this thread. So the solution for the new request will not be so easy searchable.
 
Upvote 0
Is there a reverse way do this? that is to extract Sheets names from my workbook and list them in Sheet 1 A1:A250
 
Upvote 0
try this:

Code:
Option Explicit

Sub wsNameList()

Application.ScreenUpdating = False

Dim wsList As Worksheet, ws As Worksheet
Dim lSheetNameRow As Long

Set wsList = Sheet1

lSheetNameRow = 1

For Each ws In Sheets
    If Not ws.Name = wsList.Name Then
        wsList.Cells(lSheetNameRow, 1) = ws.Name
        lSheetNameRow = lSheetNameRow + 1
    End If
Next ws
   
Application.ScreenUpdating = True

End Sub
 
Upvote 0
Another question, if i don't want the name of sheets with data row less than 100 rows to be added to the name list in Sheet1, what is the codes to do this? thank you
 
Upvote 0
try this. It check number of rows in Column Q and if it >= 100 then copy Sheet Name to Sheet1

Code:
Option Explicit

Sub wsNameList()

Application.ScreenUpdating = False

Dim wsList As Worksheet, ws As Worksheet
Dim lSheetNameRow As Long

Set wsList = Sheet1

lSheetNameRow = 1

For Each ws In Sheets
    If Not ws.Name = wsList.Name Then
        If ws.Cells(10000, 17).End(xlUp).Row >= 100 Then
        wsList.Cells(lSheetNameRow, 1) = ws.Name
        lSheetNameRow = lSheetNameRow + 1
        End If
    End If
Next ws
   
Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,349
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top