Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default formula behind field on user form

Hi

I have drop down lists within a worksheet, which allow me to key in a
select the supplier, itema, itemb, and retrieve the price. I have gotten this
working perfectly by using named ranges and the following formula

=SUMPRODUCT(--(supplier=G2),--(itema=H2),--(itemb=I2), (Price))

I now want to move the functionality to a user form. I have managed to put
my named ranges into the RowSource properties of each of my list boxes on the
form, however, I need to place this formula somewhere against my 'price'
field in order that it retrieves the price based on the supplier, item etc
selecte.

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default formula behind field on user form

Lisa,

Assuming all the values are on the Userform:


Private Sub CommandButton1_Click()
Dim myform As String
myform = "SumProduct((Supplier = """ & UserForm1.TextBox1.Text & """)*(ItemA = """ &
UserForm1.TextBox2.Text & """)*(ItemB= """ & UserForm1.TextBox3.Text & """)*Price)"
Msgbox "The price for that item is " & Evaluate(myform)
End Sub

If any of the Textbox entries are numbers, then you will need to get rid of the extra "" and cast
the text into a number using CInt or CDbl....


HTH,
Bernie
MS Excel MVP


"Lisa" wrote in message
...
Hi

I have drop down lists within a worksheet, which allow me to key in a
select the supplier, itema, itemb, and retrieve the price. I have gotten this
working perfectly by using named ranges and the following formula

=SUMPRODUCT(--(supplier=G2),--(itema=H2),--(itemb=I2), (Price))

I now want to move the functionality to a user form. I have managed to put
my named ranges into the RowSource properties of each of my list boxes on the
form, however, I need to place this formula somewhere against my 'price'
field in order that it retrieves the price based on the supplier, item etc
selecte.

Thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 328
Default formula behind field on user form

Great, thanks Bernie. I'd like to have a field at the bottom of the form that
displays the price, rather than a button, would the macro be the same?

Will definitely give your suggestion a go anyway.

Thanks again

"Bernie Deitrick" wrote:

Lisa,

Assuming all the values are on the Userform:


Private Sub CommandButton1_Click()
Dim myform As String
myform = "SumProduct((Supplier = """ & UserForm1.TextBox1.Text & """)*(ItemA = """ &
UserForm1.TextBox2.Text & """)*(ItemB= """ & UserForm1.TextBox3.Text & """)*Price)"
Msgbox "The price for that item is " & Evaluate(myform)
End Sub

If any of the Textbox entries are numbers, then you will need to get rid of the extra "" and cast
the text into a number using CInt or CDbl....


HTH,
Bernie
MS Excel MVP


"Lisa" wrote in message
...
Hi

I have drop down lists within a worksheet, which allow me to key in a
select the supplier, itema, itemb, and retrieve the price. I have gotten this
working perfectly by using named ranges and the following formula

=SUMPRODUCT(--(supplier=G2),--(itema=H2),--(itemb=I2), (Price))

I now want to move the functionality to a user form. I have managed to put
my named ranges into the RowSource properties of each of my list boxes on the
form, however, I need to place this formula somewhere against my 'price'
field in order that it retrieves the price based on the supplier, item etc
selecte.

Thanks in advance




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default formula behind field on user form

Lisa,

The macro to evaluate the sumproduct expression would be essentially the same, but you would need to
tie it to a change event, and do some error checking for blank fields, perhaps.

HTH,
Bernie
MS Excel MVP


"Lisa" wrote in message
...
Great, thanks Bernie. I'd like to have a field at the bottom of the form that
displays the price, rather than a button, would the macro be the same?

Will definitely give your suggestion a go anyway.

Thanks again

"Bernie Deitrick" wrote:

Lisa,

Assuming all the values are on the Userform:


Private Sub CommandButton1_Click()
Dim myform As String
myform = "SumProduct((Supplier = """ & UserForm1.TextBox1.Text & """)*(ItemA = """ &
UserForm1.TextBox2.Text & """)*(ItemB= """ & UserForm1.TextBox3.Text & """)*Price)"
Msgbox "The price for that item is " & Evaluate(myform)
End Sub

If any of the Textbox entries are numbers, then you will need to get rid of the extra "" and cast
the text into a number using CInt or CDbl....


HTH,
Bernie
MS Excel MVP


"Lisa" wrote in message
...
Hi

I have drop down lists within a worksheet, which allow me to key in a
select the supplier, itema, itemb, and retrieve the price. I have gotten this
working perfectly by using named ranges and the following formula

=SUMPRODUCT(--(supplier=G2),--(itema=H2),--(itemb=I2), (Price))

I now want to move the functionality to a user form. I have managed to put
my named ranges into the RowSource properties of each of my list boxes on the
form, however, I need to place this formula somewhere against my 'price'
field in order that it retrieves the price based on the supplier, item etc
selecte.

Thanks in advance






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Active X Controls Tabbing from Form Field 2 Form Field Tfrup12 Excel Discussion (Misc queries) 0 February 19th 08 08:15 PM
user form, field split??? Rominall Excel Programming 1 November 19th 07 03:12 PM
User form to change manual field filter in pivot table bennyob Excel Discussion (Misc queries) 0 March 7th 07 01:00 PM
Can you put a formula on a field that requires user input? Nan Excel Programming 2 February 15th 06 07:06 PM
User Form Formula sbruner Excel Programming 3 July 19th 05 10:56 PM


All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"