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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading from two cells in an excel spreadsheet

Status
Not open for further replies.

tydee

Programmer
Feb 4, 2010
6
ZA
i need to read data from excel and store it in a database(SQL server 2005).I am doing this using vb.While reading i need to keep track of values fro two positions in excel.(ie two diffrent cells or ranges) how do i go about this.
 
Hallo,

Try something like:
Code:
  Dim objExcel As Object
  Dim objSpreadsheet As Object
  Set objExcel = CreateObject("Excel.Application")
  objExcel.Workbooks.Open "C:\MySpreadsheet.xls"
  objSpreadsheet = objExcel.Workbooks(1).WorkSheets(2) 'Or whatever
  Debug.Print "Cell at Row=3, Col=4 on Worksheet=2, Wookbook=1 is " & objSpreadsheet.cells(3, 4))

From that you should be able to look up how to do ranges.

- Frink
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top