Forum Discussion

tpoirier's avatar
tpoirier
Contributor
13 years ago

How to read data from another sheet in Excel

I am working toward reading user data from the first sheet on an excel file and then using the second to build the test data. 



How do I get Excel to read data from the second sheet? 



I've tried the following: (JScript)



MySheet = xlFile.Sheets('Sheet2');



cell = VarToStr(Excel.MySheet.Cells(m, u));



Except it gives me an error on the MySheet saying its null, or if I put it all inline it will come back with the error 'Expected ; '



Any ideas?



2 Replies

  • Hi T Poirier,

    from an Excel - COM object the command to call the second sheet should be :



    MySheet = XlFile.Sheets.Item("Sheet2")

    MySheet.Activate();



    Regards,

    Christophe
  • Thanks for the reply! I figured it out and I used:



    Excel.Sheets(1).Cell(1, 2) - Reads data out of cell 1, 2 from the first sheet