thechazm
VBA, VB.net, C#, Java
- Local time
- Today, 10:21
- Joined
- Mar 7, 2011
- Messages
- 515
That's actually a simple fix. All you need to do is change the step number from 1 to 2. Here is the modifed piece of code highlighted in red where you need to change it.
Code:
Function GetDataFromExcelSheets(lSheetNumber As Long)
Dim xlsApp As Excel.Application, xlsWorkBook As Excel.Workbook, xlsSheet As Excel.Worksheet
Dim db As Database, rs As DAO.Recordset
ReDim Arr(1 To 100)
'On Error GoTo ErrHandler
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from [IDMSummary]", dbOpenDynaset)
BrowseFile "CSV"
Set xlsApp = New Excel.Application
For x = LBound(Arr) To UBound(Arr)
If CStr(Arr(x)) = "" Then Exit For
Set xlsWorkBook = xlsApp.Workbooks.Open(CStr(Arr(x)))
Set xlsSheet = xlsApp.Worksheets(lSheetNumber)
For i = 2 To xlsSheet.Cells(Rows.Count, "A").End(xlUp).Row [COLOR=red]Step 2[/COLOR] ' Starts at row 3 in excel sheet and gets a total row count on column O. & _
If your longest column is different then change the letter to that column. Also if your data starts on a different row make sure to change the 3 to whatever number it needs to be.
' Do operations here on the excel sheets
'Debug.Print xlsSheet.Cells(i, 15) ' Prints out column 15 data in the immediate window
With rs
.AddNew
![SpreadsheetName] = xlsSheet.Name
![Total Number of checks inserted into device] = xlsSheet.Cells(i, 1)
![Checks moved to escrow] = xlsSheet.Cells(i, 2)
![Checks accepted by host] = xlsSheet.Cells(i, 3)
![Checks rejected by non-hardware logic] = xlsSheet.Cells(i, 4)
![Checks rejected by hardware] = xlsSheet.Cells(i, 5)
![Number of Checks Rejected by Image Too Light] = xlsSheet.Cells(i, 6)
![Number of Checks Rejected by Image Too Dark] = xlsSheet.Cells(i, 7)
![Number of Checks Rejected by Excessive Skew] = xlsSheet.Cells(i, 8)
![Number of Checks Rejected by Out Of Focus] = xlsSheet.Cells(i, 9)
' Fill in the rest of the field information here
.Update
End With
Next i
Next x
xlsApp.Quit
Set xlsSheet = Nothing
Set xlsWorkSheet = Nothing
Set xlsApp = Nothing
Exit Function
ErrHandler:
MsgBox Err.Number & " - " & Err.Description
Set xlsSheet = Nothing
Set xlsWorkSheet = Nothing
Set xlsApp = Nothing
End Function