Using Regular Expressions:
For a UDF, which can be placed in any cell and refer to any cell:
e.g. =Get6Digit(F1)
===========================================
Option Explicit
Function Get6Digit(s As String) As String
Dim re As Object, mc As Object
Set re = CreateObject("vbscript.regexp")
re.Pattern = "\b\d{6}\b"
If re.test(s) = True Then
Set mc = re.Execute(s)
Get6Digit = mc(0).Value
End If
End Function
============================================
For a Macro, which can be coded to work on a particular range of cells:
=============================================
Option Explicit
Sub Move6Digits()
Dim rSrc As Range, rDest As Range, c As Range
Dim re As Object, mc As Object
Dim s As String
Set re = CreateObject("vbscript.regexp")
Set rSrc = Range("F1", Cells(Rows.Count, 6).End(xlUp))
Set rDest = Range("J1")
re.Pattern = "\b\d{6}\b"
For Each c In rSrc
rDest(1, 1).Value = ""
rDest(1, 1).NumberFormat = "@"
s = c.Value
If re.test(s) = True Then
Set mc = re.Execute(s)
rDest(1, 1).Value = mc(0).Value
End If
Set rDest = rDest(2, 1)
Next c
End Sub
===============================================
The Pattern "\b\d{6}\b" in each case looks for the first set of 6 consecutive
digits that exists as a stand-alone word.
--ron