09-21-2022
12:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-21-2022
12:07 PM
Hi @steveh3. I didn't have time to create a complete solution for you today, but I did create something to get you further along in your project. It is difficult to get data from Excel in a 2-dimensional array using iLogic's built-in GoExcel functions, so I opted for digging into Excel's API for this one. This will get the Excel data to a 2D array for you. Then just to show you that it worked, I included a message at the end that shows you the values across the last line of data. The comparisons and filtering can be added later.
This is the code I have for you right now.
AddReference "Microsoft.Office.Interop.Excel.dll"
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Excel
Sub Main
Dim oFile As String = "C:\Temp\Wheel_database.xlsx"
Dim oSheet As String = "FormedPlates"
'start a new instance of Excel
Dim oExcel As New Excel.Application
oExcel.DisplayAlerts = False
oExcel.Visible = True
Dim oWB As Workbook = oExcel.Workbooks.Open(oFile)
Dim oWS As Worksheet = oWB.Sheets.Item(oSheet)
'specify the range of cells in that sheet you want to read into memory
Dim oRange As Range = oWS.Range("A1:D32")
'create 2-dimensional array of Object, and set the range's values into it
Dim oArray(, ) As Object = oRange.Value
'read from an array by specifying row, then column, both starting with 1
Dim oLastRowData As String
oLastRowData = oArray(32, 1).ToString
oLastRowData = oLastRowData & " <> " & oArray(32, 2).ToString
oLastRowData = oLastRowData & " <> " & oArray(32, 3).ToString
oLastRowData = oLastRowData & " <> " & oArray(32, 4).ToString
MsgBox("oLastRowData = " & oLastRowData,,"")
oWS = Nothing
oWB.Close
oWB = Nothing
'oExcel.Quit
oExcel = Nothing
End Sub
Wesley Crihfield
(Not an Autodesk Employee)