VBA Macro Problem

Andy0311

Board Regular
Joined
Oct 16, 2019
Messages
118
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hello,

I work for an online school and supervise 31 teachers. Twice a month, I run a report which gives me the number of hours each teacher has spent online. I output the report in an excel workbook. The output has 31 tabs for each teacher's information. The tabs are Sheet 1, Sheet 2, etc. I recorded a macro renaming each tab with the name of the teacher, so I wouldn't have to type each teacher's name every time I ran the report. Whe I tried to run the macro I got this error message:

Run-time error '9':

Subscript out of range

When I clicked on debug (I cannot debug VBA), I got this:

Sub SeatTabs()
'
' SeatTabs Macro
'

'
Sheets("1").Select
Sheets("1").Name = "Allen-Harmon"
Sheets("2").Select
Sheets("2").Name = "Allison"
Sheets("3").Select
Sheets("3").Name = "Baratko"
Sheets("4").Select
Sheets("4").Name = "Barot"
Sheets("5").Select
Sheets("5").Name = "BeisnerA"
Sheets("6").Select
Sheets("6").Name = "BeisnerD"
Sheets("Sheet7").Select
Sheets("Sheet7").Name = "BurchfieldG"
Sheets("Sheet8").Select
Sheets("Sheet8").Name = "BurchfieldT"
Sheets("Sheet9").Select
Sheets("Sheet9").Name = "Elliott"
Sheets("Sheet10").Select
Sheets("Sheet10").Name = "Fogle"
Sheets("Sheet11").Select
Sheets("Sheet11").Name = "Goubeaux"
Sheets("Sheet12").Select
Sheets("Sheet12").Name = "GriffithJ"
Sheets("Sheet13").Select
Sheets("Sheet13").Name = "GriffithM"
Sheets("Sheet14").Select
Sheets("Sheet14").Name = "Harris"
Sheets("Sheet15").Select
Sheets("Sheet15").Name = "Hellemann"
Sheets("Sheet16").Select
Sheets("Sheet16").Name = "HelsingerJ"
Sheets("Sheet17").Select
Sheets("Sheet17").Name = "HelsingerP"
Sheets("Sheet18").Select
Sheets("Sheet18").Name = "Jones"
Sheets("Sheet19").Select
Sheets("Sheet19").Name = "Koch"
Sheets("Sheet20").Select
Sheets("Sheet20").Name = "Leibold"
Sheets("Sheet21").Select
Sheets("Sheet21").Name = "Little"
Sheets("Sheet22").Select
Sheets("Sheet22").Name = "Lorz"
Sheets("Sheet23").Select
Sheets("Sheet23").Name = "MerkC"
Sheets("Sheet24").Select
Sheets("Sheet24").Name = "MerkJ"
Sheets("Sheet25").Select
Sheets("Sheet25").Name = "Miller"
Sheets("Sheet26").Select
Sheets("Sheet26").Name = "Mitter"
Sheets("Sheet27").Select
Sheets("Sheet27").Name = "Saylor"
Sheets("Sheet28").Select
Sheets("Sheet28").Name = "Seitz"
Sheets("Sheet29").Select
Sheets("Sheet29").Name = "Showalter"
Sheets("Sheet30").Select
Sheets("Sheet30").Name = "Statt"
Sheets("Sheet31").Select
Sheets("Sheet31").Name = "Swiger"
Range("M31").Select
End Sub


I don't know how to proceed at this point, or if the macro I need is possible. Any help would be appreciated. Thanks, again.

Andy
 
Cross posted https://www.excelforum.com/excel-pr...-workbook-tabs-does-not-work.html#post5211349

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

Why did you do this over an hour after we tried to help?
Did you try my code from post#9, or am I just wasting my time the same way people on ExcelForum are?
 
Last edited:
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Cross posted https://www.excelforum.com/excel-pr...-workbook-tabs-does-not-work.html#post5211349

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

Why did you do this over an hour after we tried to help?
Did you try my code from post#9, or am I just wasting my time the same way people on ExcelForum are?


You absolutely helped me and I wrote you a thanks. Sorry this irritated you. This is my first day here, and I will not cross-post again. Thanks again. A
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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