Results 1 to 3 of 3

Thread: An Excel Quickie

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    39

    Talking

    Whilst either opening a new or existing excel sheet to add in data, it always defaults to sheet 4 (1 sheet after the amount of sheets in the xls.), ie when I create a new excel spreadsheet there are by default 3 sheets, so when I add a sheet and enter data it is on sheet 4, anyone know how I can refer to a particular sheet on an excel spreadsheet in code (I want nothing to do with Macros thanks).

  2. #2
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    No worries.

    Code:
        Dim xlAPP As New Excel.Application
        Dim xlWB As Excel.Workbook
        Dim xlWS As Excel.Worksheet
        
        'open a workbook
        Set xlWB = xlAPP.Workbooks.Open("test.xls")
        'set the worksheet to the first one.
        Set xlWS = xlWB.Sheets(1)
    Iain, thats with an i by the way!

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    39

    Thumbs up

    That did the trick nicely. Thank you.


Posting Permissions

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



Click Here to Expand Forum to Full Width