Extract text from string

saltkev

Active Member
Joined
Oct 21, 2010
Messages
324
Office Version
  1. 2013
Platform
  1. Windows
VBA

Good Morning Guys
I hope you can help. I need to extract specific pieces of text from a string. The string will differ in length but will keep the same format between "/"

The pieces of text are identified in RED. There will thousands of lines so I will run it through a For Loop

2 ;V5745463100800/UBN1/N/1/0/10/50313213/1

Many Thanks

Kev

 
How about this tweak to Peter's code
VBA Code:
.Offset(, 2).Value = Evaluate(Replace("if({1},trim(mid(substitute(#,""/"",REPT("" "",100)),500,100)))", "#", .Address))
 
Upvote 0
Solution

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Glad we could help & thanks for the feedback.
 
Upvote 0
Try this code . Data starts from A3 and down. From B3 And C3 O/p result will be available.

VBA Code:
Sub GetStrings()
Dim A, M, N
Dim Ros As Long, T As Long

A = Range("A3").CurrentRegion
Ros = UBound(A, 1)
ReDim B(1 To Ros, 1 To 1)
ReDim C(1 To Ros, 1 To 1)
For T = 1 To Ros
M = Split(A(T, 1), ";")
N = Split(M(1), "/")
B(T, 1) = N(0): C(T, 1) = N(5)
Next T
With Range("A3").Resize(Ros, 1)
.Offset(0, 1) = B
.Offset(0, 2) = C
End With
End Sub
 
Upvote 0
Try this code . Data starts from A3 and down. From B3 And C3 O/p result will be available.

VBA Code:
Sub GetStrings()
Dim A, M, N
Dim Ros As Long, T As Long

A = Range("A3").CurrentRegion
Ros = UBound(A, 1)
ReDim B(1 To Ros, 1 To 1)
ReDim C(1 To Ros, 1 To 1)
For T = 1 To Ros
M = Split(A(T, 1), ";")
N = Split(M(1), "/")
B(T, 1) = N(0): C(T, 1) = N(5)
Next T
With Range("A3").Resize(Ros, 1)
.Offset(0, 1) = B
.Offset(0, 2) = C
End With
End Sub
Works a Treat Thanks
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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