Macro to copy a sheet, rename it with user input and create a hyperlink that direct to that new sheet

orange12345

New Member
Joined
Jan 25, 2016
Messages
40
Office Version
  1. 365
Platform
  1. Windows
Hi there, I hope everyone is staying well and healthy.
I have a macro task: I'm building a student review workbook.
The first sheet is a consolidated student record sheet with each row has a student's first name, last name, score extra.
The second sheet is the individual template. Then followed the second sheet is the individual sheet for each student in the first sheet.
I'd like to give user ability to add a new student on the first sheet whenever needed and once they fill out the row, and click an add button. It will ask them the name of the sheet they would like and then the macro will copy the template sheet, fill out a few information on the template using the teacher filled info and rename it with the user-defined name, and on the same row of the first sheet, there would be a hyperlink created that once user clicked on that, it will direct them to that student sheet.

Thanks a lot. I was able to find macros that copy the template and create a new one. However, I didn't find a way to add the function for the hyperlink. I hope to get insights. Below is the macro I"m using for copying and renaming. Just the hyperlink part is missing.

Public Sub Copysheetandrename()
Dim newName as string
On Error Resume Next
NewName=InputBox("Enter the student name for the copied worksheet","Copy worksheet",ActiveCell.Value)
If newName<>""Then
ThisWorkbook.Worksheets("Templates").Copy Before:=Worksheets(sheets.Count)
On Error Resume Next
Activesheet.Name=NewName
End if
End sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,215,584
Messages
6,125,677
Members
449,248
Latest member
wayneho98

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