Remove part of a sting in a cell

jo_jan

New Member
Joined
Feb 12, 2019
Messages
5
I would like to split the date next to my text in the cell below using a vba code, but the text will sometimes change and i only want the text in the first cell, not the date.
The first column of my table is what I have and the right column is what I want.


JOHN (02/02/19)JOHN
02/02/19

<tbody>
</tbody>
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Will the date always be at the end? Do you want the end result in the first column or copied somewhere else?
 
Upvote 0
The date I want is the one written next to JOHN. Thew result I want is only 2 columns with the text and the date under. I don't want to keep the first column.
 
Upvote 0
Can you give us a few more examples of what you data looks like? For example, can there be more than 2 or 3 words in the cells? Is the date always at the end of the cell?
 
Upvote 0
Can you give us a few more examples of what you data looks like? For example, can there be more than 2 or 3 words in the cells? Is the date always at the end of the cell?

No there is only one word before the date and there is always a space between them. And yes the date is always at the end of the cell! Thanks!
 
Upvote 0
Try this macro. It assumes your data starts in row 2. If it starts in row 1, change the 2 (in red) to a 1.
Code:
Sub RemoveSubstring()
    Application.ScreenUpdating = False
    Dim LastRow As Long, x As Long, splitRng As Variant
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    For x = LastRow To [COLOR="#FF0000"]2 [/COLOR]Step -1
        splitRng = Split(Cells(x, 1), " ")
        Rows(x + 1).Insert
        Cells(x + 1, 1) = splitRng(1)
        Cells(x, 1) = splitRng(0)
    Next x
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,074
Messages
6,128,649
Members
449,462
Latest member
Chislobog

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