VBA insert formula using textbox values.

Klturi421

New Member
Joined
Aug 31, 2014
Messages
49
Once I create a sheet I want an overview sheet pull specific values from the newly created sheet. I would like to be able to use the textbox values to be inserted into the formula but the code that I have does not work. ANy suggestions or do I have some misplaced punctuation?

Code:
Range("C1").Formula = "='UserForm.TextBox1.value & "" "" & UserForm.TextBox2.value'!L5"

Thanks in advance!
 

Some videos you may like

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

sericom

Well-known Member
Joined
Jan 19, 2006
Messages
915
Does this work

Code:
Range("C1").Formula = "='" & UserForm.TextBox1.Value & " " & UserForm.TextBox2.Value & "'!L5"

Your user form may actually be called UserForm1, so add the 1 if that's the case
 

Watch MrExcel Video

Forum statistics

Threads
1,123,530
Messages
5,602,196
Members
414,513
Latest member
junbuggle

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