bananatang
08-22-2009, 06:49 PM
Hi,
Need some help here, please.....
I have set up a macro that will copy data from a userform to a new worksheet and the macro will name the worksheet as per a pre determined text box on the userform. The pre determined text box will contain a students name.
i need to amend the code in the event a worksheet with the name already exists. i would like to macro to add a number to the name. i.e. if a pupil worksheet already exists for Joe Bloggs. I would like the macro to rename the worksheet Joe Bloggs1 or if Joe bloggs1 already exist to rename as Joe Bloggs2
And if possible to have a msgbox to let the user know prior to executing the macro a students already exists with this name.
The current code i have is as follows
Worksheets("Attendance Template").Copy Before:=Worksheets(Worksheets.Count)
Set sh = ActiveSheet
sh.Name = Txtq1
Thanks
Need some help here, please.....
I have set up a macro that will copy data from a userform to a new worksheet and the macro will name the worksheet as per a pre determined text box on the userform. The pre determined text box will contain a students name.
i need to amend the code in the event a worksheet with the name already exists. i would like to macro to add a number to the name. i.e. if a pupil worksheet already exists for Joe Bloggs. I would like the macro to rename the worksheet Joe Bloggs1 or if Joe bloggs1 already exist to rename as Joe Bloggs2
And if possible to have a msgbox to let the user know prior to executing the macro a students already exists with this name.
The current code i have is as follows
Worksheets("Attendance Template").Copy Before:=Worksheets(Worksheets.Count)
Set sh = ActiveSheet
sh.Name = Txtq1
Thanks