Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    I would like to know how to add a sheet in a workbook.

    I would also like to rename a sheet in a workbook.

    Both of these i wish to do from Access using automation to Excel.

    Are they possible?

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='patt' post='766343' date='20-Mar-2009 13:38']I would like to know how to add a sheet in a workbook.

    I would also like to rename a sheet in a workbook.

    Both of these i wish to do from Access using automation to Excel.

    Are they possible?[/quote]
    As far as I know i can do the following:

    To add a sheet i just use:
    .sheets.add this will create a sheet called sheet1 as long as sheet1 does not exist.

    To rename a sheet i just:
    .sheets("sheet1").name="new sheet name"

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    [quote name='patt' post='766346' date='20-Mar-2009 05:21']As far as I know i can do the following:

    To add a sheet i just use:
    .sheets.add this will create a sheet called sheet1 as long as sheet1 does not exist.

    To rename a sheet i just:
    .sheets("sheet1").name="new sheet name"[/quote]
    Rather than assuming that the new sheet will be called sheet1, you could use
    sht = .sheets.add(type:=xlWorksheet, count:=1, after:=.sheets(1))
    sht.name = "new sheet name"

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='StuartR' post='766349' date='20-Mar-2009 19:26']Rather than assuming that the new sheet will be called sheet1, you could use
    sht = .sheets.add(type:=xlWorksheet, count:=1, after:=.sheets(1))
    sht.name = "new sheet name"
    [/quote]


    Good point, thanks stuart.

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    Don't forget Set:
    Code:
    Set sht = .sheets.add(type:=xlWorksheet, count:=1, after:=.sheets(1))
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •