Re: going thru excel grid
Quote:
Originally posted by Brandon141
Im not sure if i am on the right track at all. What i want to do is loop thru an excel spreadsheet a import the values from each cell. I have searched thru the forum and havent found anything that really helps me, most of it actually really confuses me. So any advice would be much appreciated. Thank
Code:
Private Sub cmdUpdate_Click()
Dim lRow As Long, lCol As Long, dValue As Double, dYear As Integer, dID As String
Dim obExcelApp As Excel.Application
Dim obWorkBook As Excel.Workbook
Set obExcelApp = CreateObject("Excel.Application")
Set obWorkBook = obExcelApp.Workbooks.Open("C:\windows\desktop\dfo project\temp.xls")
For lRow = 1 To 'not sure what to put here i know its the last row of the excel sheet
For lCol = 1 'not sure what to put here
dValue = Cells(lRow, lCol).Value
MsgBox dValue ' will do something here later once i get the data in
Next lCol
Next lRow
Set obWorkBook = Nothing
Set obExcelApp = Nothing
End Sub
Do you really want all 63,000 rows?
VB Code:
Private Sub cmdUpdate_Click()
Dim lRow As Long, lCol As Long, dValue As Double, dYear As Integer, dID As String
Dim obExcelApp As Excel.Application
Dim obWorkBook As Excel.Workbook
Dim c As Excel.Range
Set obExcelApp = CreateObject("Excel.Application")
Set obWorkBook = obExcelApp.Workbooks.Open("C:\windows\desktop\dfo project\temp.xls")
For Each c In Excel.ActiveSheet.UsedRange
dValue = c.Value
MsgBox dValue ' will do something here later once i get the data in
Next c
Set obWorkBook = Nothing
Set obExcelApp = Nothing
End Sub
Do you really want all 63,000 rows???
no, i wanna get from column 2 to 13 and from row 3 to 33. Sorry, i should have been more specific. Thanks