Userform Help

hemant1

New Member
Joined
Mar 11, 2012
Messages
37
Firstly I'd like to thank anyone in advance who tries to help me :)
Here is a pic of my form:

hemant_01


Okay so basically within the Product ID Combo box I'd like it to display the whole item and not just the Item code

With the Price label (lblPriceformula) I'd like it to do a Vlookup from the Product ID to find a Price, I've got a list of prices which are on the next column to the Product name and have defined these as Pricelist but after alot! of google searches I can't seem to find out how to use this.

Lastly for the TotalPrice label how would I got about multiplying the quantity with the Price? I had a thought that it could be =txtQty*lblPriceformula but I really doubt its gonna work :l

At the moment I'm using 3 named ranges (LookupLists is the sheets name)
LocationList (Which refers to the supplier combobox)

Code:
=OFFSET(LookupLists!$E$2,0,0,COUNTA(LookupLists!$E:$E)-1,1)

PartIDList (Which refers to the Product ID)

Code:
=OFFSET(LookupLists!$A$2,0,0,COUNTA(LookupLists!$A:$A)-1,1)

PartsLookup (Which is the item name)

Code:
=OFFSET(PartIDList,0,0,,2)

The Price lookup I have made is : (not sure if this one is right though)

PriceList

Code:
=OFFSET(LookupLists!$C$2,0,0,COUNTA(LookupLists!$C:$C)-1,1)


The code I'm using at the moment is from a tutorial and is :

Code:
Private Sub UserForm_Initialize()
Dim cPart As Range
Dim cLoc As Range
Dim ws As Worksheet
Set ws = Worksheets("LookupLists")

For Each cPart In ws.Range("PartIDList")
  With Me.cboPart
    .AddItem cPart.Value
    .List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
  End With
Next cPart

For Each cLoc In ws.Range("LocationList")
  With Me.cboLocation
    .AddItem cLoc.Value
  End With
Next cLoc

Me.txtDate.Value = Format(Date, "Medium Date")
Me.txtQty.Value = 1
Me.cboPart.SetFocus

End Sub

I am pretty much a noob with code and thank you again for helping :) Oh and if you need any more info please dont hesitate to ask
 
Last edited:
I think you would need to upload a sample workbook some where so that someone can take a look. If I understand this you want data to appear on a form, once you select from a combo and then do some stuff and work out a total price is that correct?

If you can get it uploaded (perhaps use Google or Microsoft) then I will take a look for you.
 
Upvote 0
You don't need a Vlookup to get the price.

You should be able to use the named range of prices with the ListIndex from the parts combobox.

Code:
lblPriceformula.Caption = Range("Pricelist").Cells(cboPart.ListIndex + 1).Text
As for multiplying the price and quantity you can try this.
Code:
lblTotalPrice.Caption =Val(txtQty.Value)*Val(lblPriceformula.Caption)
Note this won't work if the price is formatted as currency.
 
Upvote 0
I think you would need to upload a sample workbook some where so that someone can take a look. If I understand this you want data to appear on a form, once you select from a combo and then do some stuff and work out a total price is that correct?

If you can get it uploaded (perhaps use Google or Microsoft) then I will take a look for you.

Yh I would've uploaded but I can't because of it being cw and stuff but thank you anyway :)

You don't need a Vlookup to get the price.

You should be able to use the named range of prices with the ListIndex from the parts combobox.

Code:
lblPriceformula.Caption = Range("Pricelist").Cells(cboPart.ListIndex + 1).Text
As for multiplying the price and quantity you can try this.
Code:
lblTotalPrice.Caption =Val(txtQty.Value)*Val(lblPriceformula.Caption)
Note this won't work if the price is formatted as currency.

It worked! :) but do you know how to make it happen automatically instead of having it done once you click the label? so I mean as soon as I choose the product it automatically updates the price?
 
Upvote 0
Use the Combo Event After Update and add the code in there.
 
Upvote 0
On your userform you have a drop down which lists your products, this a combo box, in design view of the form, you double click the combo to go into the code behind it, then at the top right it lists your procedures, so you click the list and look for After Update. Then add the code in there.
 
Upvote 0

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