Create a new worksheet with macro. Needs to check worksheet names, to make the new name. And add some new formul.

idont

New Member
Joined
Dec 13, 2018
Messages
2
Hi,

I'm making a "userdatabase".

My exceldocumenct contains these sheets:
Overview - Will automatically look through User1 to User150 to make some graphs.
Users - A list with all users
User1 - The database with userinfo
User150 - The database with userinfo
Template - The database template for userinfo.

In Users I want to have a button that says Create new user so when I hit it, I want excel/macro to make a copy of Template, check what sheet name is available after User1, give it that name, in this case User2 and place it after User1. I also want some data changed in cell E2, E3, E4, E5, E6 in the new worksheet, really just a number. So for User1, the cell E2 contains this: =Users!E7 so in worksheet User2, this cell should contain =Users!E8

Anyone have some code I could try out?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hello,

Does this work as expected?

Code:
Sub CREATE_NEW_USER()
    Sheets("Template").Copy Before:=Sheets(Sheets.Count - 1)
    ActiveSheet.Name = ("User" & Sheets.Count - 4)
    Range("E2").Formula = "=USERS!E" & Sheets.Count + 2
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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