create button to add new sheet in first sheet and calculate including newly added sheet

prakashkumar

New Member
Joined
May 9, 2021
Messages
42
Office Version
  1. 2010
Platform
  1. Windows
hi all ,
create button in sheet 1 and name as menu , if i press on button , new sheet should create and name as page 1 at the same time A1 (of page1) cell value should display in menu page.
then ,
f i press on button , new sheet should create and name as page 2 at the same time A1 (of page2) cell value should display in menu page.

OR

create button in sheet 1 and name as menu , if i press on button , new sheet should create and name as page 1 and at the same time A1 (of page1) cell value should add A1 (menu page).
and so on,,,,,,,,
if i press 5 times on button 5 sheets should be created and what ever the values entered in cell A1 of each cell must be added in A1 of menu page

my theme is to create monthly expenditure and all ll be displayed in main menu page

thanking u sir
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I'm not clear on what you actually wanted to be brought into the Menu sheet. I populated the inserted sheet names into column A.

Here is the code that you can assign to a button on the Menu sheet.

VBA Code:
Sub AddNewPage()
    Dim n As Long
    Dim p As Range
    
    Application.ScreenUpdating = False
    
    Set p = Cells(Rows.Count, 1).End(xlUp)
    
    If InStr(1, p, " ") = 0 Then
        n = 1
    Else
        n = Mid(p, InStr(1, p, " ") + 1, Len(p)) + 1
    End If
    
    Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)).Name = "Page " & n
    ThisWorkbook.Worksheets("Menu").Activate
    p.Offset(1, 0) = "Page " & n
    
    Application.ScreenUpdating = True
End Sub

1629436634350.png
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

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