Convert values from one textbox to the next

tortillachips

New Member
Joined
Aug 9, 2011
Messages
5
I created a multipage userform in VBA. On one page of the userform I have the user input a range in meters. On a separate page of the same form I want to create a button to bring those same range values in (except this time in feet). When I try this I get a type mismatch error. Can anyone help me do this while still using an array to avoid my code being extremely lengthy. You can find the code below..

Dim x as integer
For x = 1 to 10
Me.Controls("TxtFRange" & x).Value = Me.Controls("TxtRange" & x).Value * 3.2808
Next x

Thank you!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi

Do you refer to the correct page in your multipage?

I bet you get errors since controls are on a different page.
 
Upvote 0
The code works if I take out the "* 3.2808". As far as I can tell it has something to do with mixing the control value with a number but I'm not sure how to get around it.
 
Upvote 0
Code:
Dim x as integer
For x = 1 to 10
Me.Controls("TxtFRange" & x).Text = CDbl(Me.Controls("TxtRange" & x).Text) * 3.2808
Next x
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,703
Members
452,938
Latest member
babeneker

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