Thank you Rick, Peter, Ron. After running the macro's and seeing the
results, I discovered some returning words and short phrases, which I
first have to filter-out/move a column to the right,
before running your macro. Some input is not like Place but like Place
Area Two, so to keep that together in one cell after splitting, I
first move the Other Informartion (which is "always the same start
text") and then do aspliton the second space. The start of the cell
is always 6 digits plus a space between the first four and last two
(like 1044 GH) so that will be kept intact after thesplit.
The first word of Other Information (Other) is always the same. If you
have any suggestions for search, select and move this content (eg
Other Information, Other Search, Other Fab) out of the cell, 3 columns
to the right, I would be happy to know.
Well, a different specification.
I interpreted your specifications as follows:
A1: original string
B1: First two words of the string
C1: Third word of the string up to but not including
the word "Other"
D1: "Other" and everything following it
Given that, it was easy to build a Regular Expression to those rules, and
implement it in VBA code. (And if your specifications are different, it would
be pretty straightforward to adjust the regex):
==========================================
Option Explicit
Sub ParseData()
Dim c As Range, rg As Range
Dim re As Object, mc As Object
Dim s As String
Dim i As Long
Set rg = Selection 'could set in different ways
Set re = CreateObject("vbscript.regexp")
With re
.Global = True
.ignorecase = True
.MultiLine = False
.Pattern = "^(\S+\s+\S+)\s+([\s\S]+)\s+(Other[\s\S]+)$"
End With
For Each c In rg
With c
.Offset(0, 1).Resize(1, 3).ClearContents
s = .Value
If re.test(s) = True Then
Set mc = re.Execute(s)
For i = 0 To 2
.Offset(0, i + 1).Value = mc(0).submatches(i)
Next i
End If
End With
Next c
End Sub
========================================
--ron- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -