VBA to update worksheet name based on cells in another worksheet

kelsyschmelsy

New Member
Joined
Nov 18, 2019
Messages
1
I have a workbook with 10 tabs. The names are generic to allow the user to update in the cell immediately to the right when they submit the excel workbook. I am new to VBA and want to know how to write a macro that will only update the worksheet tabs with Initiative 3/4/5/6/etc since Instructions/Project Official/Project Superstar are locked.

the names of the worksheets are listed below:
  1. Instructions [do not want macro to change this name]
  2. Project Official [do not want macro to change this name]
  3. Project Superstar [do not want macro to change this name]
  4. Initiative 3
  5. Initiative 4
  6. Initiative 5
  7. Initiative 6
  8. Initiative 7
  9. Initiative 8
  10. Initiative 9
The instructions tab includes a table starting in A1 with the names of all initiatives like this. The instructions tab also dictates the names of the initiatives and consequently, the workbooks. Is it possible to write VBA to change the names of the worksheet?:

A
1Instructions
2Project Official
3Project Superstar
4Initiative 3
5Initiative 4
6Initiative 5
7Initiative 6
8Initiative 7
9Initiative 8
10Initiative 9
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try this

VBA Code:
Sub update_worksheet_name()
  Dim sh As Worksheet, i As Long
  Set sh = Sheets("Instructions")
  For i = 4 To Range("A" & Rows.Count).End(xlUp).Row
    If i < Sheets.Count Then
      Sheets(i).Name = sh.Range("A" & i).Value
    End If
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

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