Userform without variables declared

bugatti79

Board Regular
Joined
Feb 18, 2012
Messages
70
Folks,

I have a userform which contains a number of sub procedures. Because there are no variables declared, I dont know how to use a certain value retrieved in one sub procedure and put it in another procedure.

I have attached 2 sub procedures. The first 1 retrieves a value from a table. The 2nd sub contains some calculations. I want to put the value of 'Property_E' in place of '1000'

Rich (BB code):
Private Sub ComboBox1_Change()

Dim ws As Worksheet
    Set ws = Worksheets("Table of Material Data")
    
        Property_E = Application.WorksheetFunction.VLookup(Me.ComboBox1.Value, ws.Range("A2:H18"), 2, False)


End Sub

Rich (BB code):
Private Sub TextBox2_Change()

Me.Label26.Caption = (1 * (Val(TextBox2.Value)) * 2) / (1000) ^ 2

End Sub

Any ideas?
Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
18,144
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Try a Dim statement above the first sub procedure so that either procedure recognizes the variable.
Code:
Dim Property_E as Variant
Private Sub ComboBox1_Change()
......
 
Upvote 0

Forum statistics

Threads
1,195,934
Messages
6,012,383
Members
441,693
Latest member
TraderRick

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
Top