excel multiple look up

excel multiple look up

Anonymous
Not applicable
773 Views
3 Replies
Message 1 of 4

excel multiple look up

Anonymous
Not applicable

Hi everyone.. I have an excel problem.....

 

I can imagine it is quite simple to solve but I'm struggling a little.

 

I want to run a rule that opens a spreadsheet and looks up column O for a value. if it finds it, then it deletes the value, then it moves onto the next row that has the same value in column O and deletes that value. it keeps going through the data range to the end.

 

I can open the spreadsheet, define the range, find the first row with the string and delete the contents, but that only happens if there is only one matching cell. if there are two or more cells with the string then nothing happens...

 

Can I put the code below in a loop and if so can someone help please?

 

 

'Search for the file name in column A
For oRow = RowStart To RowEnd

    If (GoExcel.CellValue("O" & oRow)) = "XXX" Then
    GoExcel.CellValue("O" & oRow) = ""
    GoExcel.Save
    GoExcel.Close
    End If
    Next

Thanks for any help

 

0 Likes
Accepted solutions (1)
774 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I figured it out... I moved the next statement...

0 Likes
Message 3 of 4

MechMachineMan
Advisor
Advisor
Accepted solution

For our next users... I'm guessing your finished code would look something like this:

 

'Search for the file name in column A

GoExcel.Open("Book1.xlsx", "Sheet1")

RowStart = 2   'Corresponds to start row
RowEnd = 100   'Corresponds to the some row just beyond the end of the dataset

For oRow = RowStart To RowEnd
    If (GoExcel.CellValue("O" & oRow)) = "XXX" Then
        GoExcel.CellValue("O" & oRow) = ""
    End if
Next

GoExcel.Save
GoExcel.Close

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 4 of 4

Anonymous
Not applicable

hi justin

 

100% correct.. I was exiting the loop after the first row was found... moving the 'Next' to come before the save/close allowed the program to save after the loop had completed...not before lol...

 

figured it out 1minute after posting... thanks for your response though....

0 Likes