Getting a value by searching another value (dictionary) with macro

  • 14 April 2021
  • 6 replies
  • 5 views

I have an Excel file with two columns (code, sum) and I want to find a specific value by searching the sum in that same row for example: I want to get the 'code' 8 by searching the sum 8000 by using an Excel macro function (or the query from excel)

example of the excel file:

 


6 replies

Hey @דניאל ליכטנשטט​ thank you for raising this question! This Excel thread might be helpful with addressing your concerns: https://community.kryonsystems.com/KryoNet/s/question/0D51o00006oiG92CAE/running-macro-from-the-studio

I know how to work with macro

I just dont know how to build this macro...

I tried some stuff but it didnt worked, so I asked here...

Hi @דניאל ליכטנשטט​ , you can use vlookup command in your macro to achieve what you want to do - sRes = Application.VLookup("8000",shData.Range("A2:B7"),2) will return 8 - adapt the range to the table range in your Excel sheet, and adapt the column of the returned value (in the example the returned value is in the 2nd column). I hope it helps

 

thats great thank u

what if I want the value that I'm searching for to be a variable (it will come from the user)

how do I accomplish that?

I wrote this macro and it gave me nothing (I'm sure that I did worng)

can u please help me with it?

this is the macro I wrote the two columns are like that (code, amount)

 

@דניאל ליכטנשטט​ 

If you want an output from macro in Kryon then need to create a function which returns a value. Like below

 

 

attaching wizard for your reference. it is build on version RPA 20.09.

Reply