Sorry, maybe I didn't make it clear enough. The numeric "1234567-123" can be any other number throughout column A.
eg:
0123456-456
7894561-789
9876543-987
Sorry, maybe I didn't make it clear enough. The numeric "1234567-123" can be any other number throughout column A.
eg:
0123456-456
7894561-789
9876543-987
Are the cells formated as "0000000-000" ?
Sub sample()
Dim r As Range
With CreateObject("VBScript.RegExp")
.Pattern = "^\d{7}-\d{3}$"
For Each r In Range("a1",Range(2a" & Rows.Count).End(xlUp))
If .test(r.Text) Then r.Offset(,1).Value = r.Offset(1).Value
Next
End With
End Sub
try
Code:Sub sample() Dim r As Range With CreateObject("VBScript.RegExp") .Pattern = "^\d{7}-\d{3}$" For Each r In Range("a1",Range("a" & Rows.Count).End(xlUp)) If .test(r.Text) Then r.Offset(,1).Value = r.Offset(1).Value Next End With End Sub
Sub sample()
Dim r As Range
With CreateObject("VBScript.RegExp")
.Pattern = "^\d{7}-\d{3}$"
For Each r In Range("a1",Range(2a" & Rows.Count).End(xlUp))
If .test(r.Text) Then r.Offset(,1).Resize(,2).Value = r.Offset(1).Resize(,2).Value
Next
End With
End Sub