Display all text before Chr(10)

jbrouse

Active Member
Joined
Apr 28, 2005
Messages
329
Greetings,

Can someone please assist me in doing the following.

I have a Text Box on my worksheet that has an OnAction macro assigned to it. The text in this textbox is in the following format (PART NAME & Chr(10) & PART NUMBER):

MOTOR
12345-678


When the Text Box is clicked, it will open up UserForm1. UserForm1 has 2 textboxes, PartName and PartNo.

I would like to pull the first line of the Text Box text into PartName and the 2nd line into PartNo.

How do I write code to pull everything up to the Chr(10) and place it into PartName and then take everything after that point and place it into PartNo?

Any assistance would be appreciated. Thanks!
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Check out the VBA functions InStr, Left, Mid, and Right. The first will tell you where in the string the Char(10) is located. The others can be used to then extract characters based on the result of the InStr.
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

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