Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

retreiving data from an open Excel sheet 1

Status
Not open for further replies.

jabond007

Programmer
Jun 21, 2000
39
US
hello,

I have a excel sheet which is being updated with share prices every minute. The first column has the stock name(ticker) and the 3rd column has the price.

I need to pick the price for a particular stock. this sheet cant be closed.

Could somebody tell me the way to do this.

Regards
 
Use the Excel object model:

Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet

Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Open("C:\aa\test.xls")
Set ws = wb.Worksheets(1)
MsgBox ws.Cells(1, 1)
MsgBox ws.Cells(1, 3)


Add looping / ... or whatever you want to get the correct share price (compare the contents of cells(1,1), cells(2,1), cells(3,1),... until you find the stock that you want and then read the relevant price from column 3)

Simon
 
PS to last post:

Don't forget to close and set the objects to Nothing to save memory.

Set ws = Nothing
wb.Close
Set wb = Nothing
Set xlApp = Nothing


Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top