
February 27th, 2012, 04:03 PM
|
|
|
|
Iterating thru cells in Excel 2010
Hello,
I am not sure why I am getting this error with line If statement in the code below...any ideas are appreciated. Get UNKNOWN RUNTIME ERROR
Code:
' do excel stuff
Set xl = CreateObject("Excel.Application")
' no need to launch excel
xl.visible = False
' specify excel file path and name
sExcelPath = CurProjDir & "\comp_pins_nets.xlsx"
'Set wb = xl.Workbooks.Open(sExcelPath)
Set wb = xl.Workbooks.Open(sExcelPath, ,ReadOnly)
Set oCurWorkSheet = wb.Worksheets("Sheet1")
'Find used rows & cols
usedColsCount = oCurWorkSheet.UsedRange.Columns.Count
usedRowsCount = oCurWorkSheet.UsedRange.Rows.Count
'Find column & row that has "Pin Name"
For row = 0 To usedRowsCount
For column = 0 To usedColsCount
If oCurWorkSheet.Cells(row, column).Value = "Pin Name" Then
iRow = row
iCol = column
End If
Next
Next
|