Adding worksheet in another workbook

Tompa70

New Member
Joined
Jan 16, 2004
Messages
4
Hi,

I have 2 workbooks and I want to add a sheet in the 2nd workbook and name the new sheet from a cell in the 1st workbook

Code after recording:

Sub veckonummer()
Range("R33").Select
Application.CutCopyMode = True
Selection.Copy
Windows("Kopia 2004.xls").Activate
ActiveSheet.Select
Application.CutCopyMode = True
ActiveSheet.Name = "0401"
Range("B1").Select
ActiveWorkbook.Save
End Sub

This row is hardcoded I want it to be as referens so if I change the "0401" it will name it according to the change.
ActiveSheet.Name = "0401"


/Thomas
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
Hi, welcome to the board.

Is this what you're looking for ?

Code:
Sub SaveOtherBook()
    With Workbooks("Kopia 2004.xls")
        .Sheets(1).Name = Range("R33").Value     'Change the name of the first sheet to the value of cell R33
        .Save    'Save that workbook
    End With
End Sub
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,832
Office Version
  1. 365
Platform
  1. Windows
How about something like:

Code:
Sub veckonummer()

    Dim myName As String
    Range("R33").Select
    myName = Range("R33").Value
    Windows("Kopia 2004.xls").Activate
    ActiveSheet.Name = myName
    Range("B1").Select
    ActiveWorkbook.Save

End Sub
 

Tompa70

New Member
Joined
Jan 16, 2004
Messages
4
Thx for the fast answers.

Both examples works fine though they change the name of an existing sheet, I want it to add a new sheet in the 2nd workbook with the value in "R33" wich changes every week. I got around to it finally.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
60,832
Office Version
  1. 365
Platform
  1. Windows
Simply add the line "Sheets.Add":

Code:
Sub veckonummer()

    Dim myName As String
    Range("R33").Select
    myName = Range("R33").Value
    Windows("Kopia 2004.xls").Activate
    Sheets.Add
    ActiveSheet.Name = myName
    Range("B1").Select
    ActiveWorkbook.Save

End Sub
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,888
Messages
5,766,948
Members
425,389
Latest member
Naresha

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
Top