Searching values in a database

odd_socks17

New Member
Joined
Jun 18, 2017
Messages
5
Hi all,
I'm writing a code which will (hopefully!) update the value of a cell which is chosen based on Userform Inputs.

I am looking for a way to find a row (and assign it to a variable which will be used to find a cell in that row) based on two variables from my Userform.
Ive tried the IF loop and MATCH methods and havent been able to get them to work (im pretty new to coding).

Sample code:
Quantity at Shop 1Quantity at Shop 2Food GroupName
32FruitApple
51FruitBanana
03VegetableCelery
64VegetableCarrot

<tbody>
</tbody>

I am hoping for a way to find, for example, Row 2, if the user inputs Fruit into a combo box on the form, and Banana in another combo box.
At the moment these combo boxes are being used to define the variable varGroup and varName.

Id like the row value to be assigned to a variable that i can use in the code i am currently using to update the quantity value, shown below:
Code:
QtyPrevious = Cells([B]varROWVALUE[/B], varColumn).Value
QtyNew = (QtyPrevious + InputQty)
Cells([B]varROWVALUE[/B], varColumn).Value = QtyNew

the variable varROWVALUE shown in bold above is what i am looking to define.

Looking for a purely VBA solution. I am using version 15 of Excel (i think!)

Any help is greatly appreciated (and needed), hope your expertise can end the frustrated hours of fruitless experiments.

Many thanks,
odd_socks :)
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
You got two fruits. From which fruit you want to take a row number?
 
Upvote 0

Forum statistics

Threads
1,215,886
Messages
6,127,575
Members
449,385
Latest member
KMGLarson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top