Sheet Names = to Variables?

StefanRSA

New Member
Joined
May 26, 2008
Messages
24
Hi Guys,

Trying to make a sheet name equal to a variable in an Worksheet_Selection Change(ByVal Target as Range) Sub...

I have tried to isolate the worksheet which I want to rename (as I dont know if they have numbers like columns references) by checking if the name of the other two worksheets equal the name I want to rename to. Obviously they do not and I was hoping I could then "select" the third worksheet and thus rename it. I have left ??? for the parameters I am missing.

Is this even possible?

If Sheets("Vanco").Name <> Sheets(Name).Name Or Sheets("LOV").Name <> Sheets(Name).Name Then

??? Sheets.Select
ActiveSheet.Name = Name
Sheets("Vanco").Select

Many thanks in advance for your consideration and suggestions.

Stefan ;)
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try:

Code:
Sub Test()
    Dim Sh As Worksheet
    For Each Sh In ThisWorkbook.Worksheets
        If Sh.Name <> "Vanco" And Sh.Name <> "LOV" Then
            Sh.Name = "TheName"
            Exit For
        End If
    Next Sh
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,034
Messages
6,122,782
Members
449,095
Latest member
m_smith_solihull

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