String Manipulation, get substring after space

Deverti

Board Regular
Joined
Sep 5, 2020
Messages
63
Office Version
  1. 365
Platform
  1. Windows
i have a repeating cell format i need to split into two parts, "Nr" and "Street, PLZ", format being: "Nr Street, PLZ"

im getting the "Nr" as needed but the "Street, PLZ" is a total screw up and im not quite sure what im doing wrong

VBA Code:
Sub StringTitleRelocate()
Dim vR As Range, vN As Variant, vT As Variant
    For Each vR In Range("C1", Range("C" & Rows.Count).End(xlUp))
        If Not IsEmpty(vR) Then
            vN = (Split(vR, " ")(0))
            vTi = (Split(vR, " ")(0))        '?'
            vT = Mid(vR, vTi)                '?'
            vR.Offset(1, 3).Value = vN
            vR.Offset(1, -2).Value = vT
        End If
        vR.ClearContents
    Next vR
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
How about
VBA Code:
Sub StringTitleRelocate()
Dim vR As Range, vN As Variant, vT As Variant
    For Each vR In Range("C1", Range("C" & Rows.Count).End(xlUp))
        If Not IsEmpty(vR) Then
            vN = Split(vR, " ", 2)
            vR.Offset(1, 3).Value = vN(0)
            vR.Offset(1, -2).Value = vN(1)
        End If
        vR.ClearContents
    Next vR
End Sub
 
Upvote 0
Oh, guess i totally misunderstood the Limit option.
That s indeed a lot better. Thanks Fluff
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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