Hello Everyone,
Currently I have a VBA Code that I use to change the names of all the tabs to a specific cell in the worksheet. See VBA Code 1. below. In this case it's "A2". I obvioulsy can change that cell to point other cells for future changes.
My question is, how can this code be modified to exclude renaming certain sheets?
I have another code the splits the sheets into their own file folder excluding the "Master Data" and "Pricing" sheets.
I have tried to blend the codes to get it to work, and I can't figure it out. I am still learning.
This was part of the code that I tried.
If xWS.Name <> "Master Data" And xWS.Name <> "Pricing"
I need to rename all the sheets to cell "DO2" excluding these two sheets "Master Data" and "Pricing"
VBA Code 1.
Sub RenameTabs()
For i = 1 To Sheets.Count
If Worksheets(i).Range("A2").Value <> "" Then
Sheets(i).Name = Worksheets(i).Range("A2").Value
End If
Next
End Sub
Thanks in advance,
Gary
Currently I have a VBA Code that I use to change the names of all the tabs to a specific cell in the worksheet. See VBA Code 1. below. In this case it's "A2". I obvioulsy can change that cell to point other cells for future changes.
My question is, how can this code be modified to exclude renaming certain sheets?
I have another code the splits the sheets into their own file folder excluding the "Master Data" and "Pricing" sheets.
I have tried to blend the codes to get it to work, and I can't figure it out. I am still learning.
This was part of the code that I tried.
If xWS.Name <> "Master Data" And xWS.Name <> "Pricing"
I need to rename all the sheets to cell "DO2" excluding these two sheets "Master Data" and "Pricing"
VBA Code 1.
Sub RenameTabs()
For i = 1 To Sheets.Count
If Worksheets(i).Range("A2").Value <> "" Then
Sheets(i).Name = Worksheets(i).Range("A2").Value
End If
Next
End Sub
Thanks in advance,
Gary