Create two strings from one based on a character?

SSjmg2477

Board Regular
Joined
Jul 20, 2005
Messages
56
How do I use a macro to create two strings from one string by breaking it up on a specific character.

Example

ABC.DEF is the current string. I need to write code that will give me two strings, ABC and DEF.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,353
Office Version
  1. 365
Platform
  1. Windows
Do you really need code for this?

It could easily be achieved using formulas or Data>Text to columns...
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,353
Office Version
  1. 365
Platform
  1. Windows
Well can you give some more information.:)

The following code will split whatever's entered in column A.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 1 And Target.Count = 1 Then
        Application.EnableEvents = False
        Target.Offset(, 1) = Mid(Target.Value, InStr(Target.Value, ".") + 1)
        Target = Left(Target.Value, InStr(Target.Value, ".") - 1)
        Application.EnableEvents = True
    End If
End Sub
 

Forum statistics

Threads
1,175,989
Messages
5,900,750
Members
434,848
Latest member
kubersood321

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