- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
goExcel.FindRow gives result of -1
I am trying to access multiple columns data on a single row that is "flagged" by a specific value (i.e. 1650).
The following code sets a parameter value "BSeries" to object Series_val and then I use goExcel.FindRow to locate the row that "BSeries" value is. But when I run the code, the messagebox shows a result of -1.
I have a form that I am using to populate parameters, based on the BSeries.
What am I doing wrong.
GoExcel.Open("C:\Users\jpetty\Documents\John's Scratch\bfd\Belt Data.xlsx", "Belt_Data")
Series_val = Parameter.Value("BSeries")
MessageBox.Show(Series_val)
j = GoExcel.FindRow("C:\Users\jpetty\Documents\John's Scratch\bfd\Belt Data.xlsx", "Belt_Data", "SERIES", "=", Series_val)
'b = GoExcel.CurrentRowValue("SERIES")
MessageBox.Show(j)
'MessageBox.Show(Parameter("BSeries"))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, many times this type of access to the Excel file has given me headaches. I take more time trying to find the error than accessing otherwise.
Below I show you a way to access an excel file.
If you find the value you are looking for in a row you can identify a value from the same row.
In order for this to work correctly and load all the values correctly, I would recommend that you load all the values in the "Series" column that are blank, because otherwise you will not take these comparison values because their value is "nothing".
Dim oValue As String = "100" Dim Dirxlsx As String = "C:\Users\Sergio\Downloads\Belt Data.xlsx" ''' Specify the template path Dim osheet As String = "Belt_Data" ''' Specify the sheet of the template xlApp = CreateObject("Excel.Application") xlApp.Visible = False xlWorkbook = xlApp.Workbooks.Open(Dirxlsx,False) xlWorksheet = xlWorkbook.Worksheets.Item(osheet) For row As Integer=2 To 147 oSeries = GoExcel.CellValue(Dirxlsx, osheet, "B" & row) If oSeries = oValue Then oStyle = GoExcel.CellValue(Dirxlsx, osheet, "C" & row) MessageBox.Show(oStyle) End If Next xlWorkbook.Close (True) xlApp.Quit
I hope this helps with your problem. regards
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
don't ask me why but it has to do with the empty cells in your series column, it probably treats the first blank cell as the end of the search range, I just filled in the empty cells with 'x's and it worked as expected.