I'm super new to VBA, so I'll try to explain thoroughly:
I have a workbook where I enter data for a specific person in each tab. There's also a master tab that rolls up this data into averages.
In order to add a new tab, I copy the tab, clear out the data, then I copy the row of formulas and do a find and replace to change the sheet name.
I recorded a macro to do all this for me, but the problem is I don't want the macro to rename each sheet "Instructor 7" each time, I need the sheet name to be "Instructor (last sheet #+1)".
Anyone know how to help me?
Here's my VBA code:
I have a workbook where I enter data for a specific person in each tab. There's also a master tab that rolls up this data into averages.
In order to add a new tab, I copy the tab, clear out the data, then I copy the row of formulas and do a find and replace to change the sheet name.
I recorded a macro to do all this for me, but the problem is I don't want the macro to rename each sheet "Instructor 7" each time, I need the sheet name to be "Instructor (last sheet #+1)".
Anyone know how to help me?
Here's my VBA code:
Code:
Sub AddNewInst()'
' AddNewInst Macro
' Adds new sheet and creates a new row in Master
'
'
Sheets("Instructor 1").Select
Sheets("Instructor 1").Copy Before:=Sheets(1)
Sheets("Instructor 1 (2)").Select
Sheets("Instructor 1 (2)").Name = "Instructor 7"
Range("B3:O30").Select
Selection.ClearContents
Range("B1").Select
Selection.ClearContents
Sheets("Master").Select
Range("A3:AB3").Select
Selection.Copy
Range("A9").Select
ActiveSheet.Paste
Selection.Replace What:="Instructor 1", Replacement:="Instructor 7", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
False, ReplaceFormat:=False
End Sub