Need macro to place a portion of textbox into cell

nicolewh

Well-known Member
Joined
Aug 7, 2009
Messages
554
I need a macro to take the numbers between two symbols in a textbox - between the second "*" and the "+" and place these values in cell A1.

Example:
*123*456+

Result: values 456 in cell A1.

or when the "+" does no exist place only the values after the second "*"

Example:
*123*456

Result: values 456 in cell A1.

If it helps the "+", when used, is always on the end of the textbox.
and the second "*" is never used unless there are numbered values after it.
And, there could be between 3 and 5 values after the second *

Little crazy! I know

Thank you

Nicole
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi Nicole

Try:

Code:
Range("A1") = Split(Replace(TextBox1.Value, "*", "+", 1, 2), "+")(2)
 
Upvote 0
Trying to adjust it to a change that I want.

instead of the * in the middle I want to use "-" instead.
example:
*123-456+

Result: 456

or
*123-456

Result: 456

How do I adjust it to do this?

Thanks!

Nicole
 
Upvote 0
Hi again

If you mean from the first "-" to the end of the string (whether it has a "+" at the end or not), try:

Code:
Range("A1") = Split(Mid(TextBox1.Value, InStr(TextBox1.Value & "+", "-") + 1), "+")(0)
 
Upvote 0

Forum statistics

Threads
1,214,625
Messages
6,120,598
Members
448,973
Latest member
ksonnia

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