Russell
I have assumed your Text-numerical data to be
in a single column ??
If so then the following macro will work.
Sub CompareTxtAlpha()
Dim IniTxt As String
Dim CmpTxt As String
Dim LenIniTxt As Integer
Dim MyRg As Range
Dim Cell2Comp
Dim x As Integer
'----------------------------------------
' Compares text in a column by
'1. Selecting the text column range
'2. Sorting in Ascending order
'3. Then Doing a partial text comparison
'----------------------------------------
'start of your Text data by column !
Range("A1").Select
Set MyRg = Range(ActiveCell, ActiveCell.End(xlDown))
MyRg.Select
Selection.Sort Key1:=MyRg, Order1:=xlAscending
For Each Cell2Comp In MyRg
Cell2Comp.Select
If Cell2Comp = "" Then GoTo NxtCell
IniTxt = Cell2Comp.Text 'Assign text to test
LenIniTxt = Len(IniTxt) 'get length so that
'we can compare ie. Text - any Numbers
For x = 1 To MyRg.Count - 1
CmpTxt = Cell2Comp.Offset(x, 0) 'Next String to compare against
'check for partial match
If IniTxt = Left(CmpTxt, LenIniTxt) Then
ActiveCell.Offset(1, 0).Select
ActiveCell.Clear
Else
If x < MyRg.Count Then
x = x + 1
End If
End If
Next x
NxtCell:
Next Cell2Comp
End Sub
regards
Ivan
Russell,
Disregard the macro I posted, realised the criteria
I set up is not what you require !!
Sorry
Ivan
Russell, had another look.
Small change gets it working.Sub CompareTxtAlpha()
Dim IniTxt As String
Dim CmpTxt As String
Dim TmpTxt
Dim LenIniTxt As Integer
Dim MyRg As Range
Dim Cell2Comp
Dim x As Integer
'----------------------------------------
' Compares text in a column by
'1. Selecting the text column range
'2. Sorting in Ascending order
'3. Then Doing a partial text comparison
'----------------------------------------
'start of your Text data by column !
Range("A1").Select
Set MyRg = Range(ActiveCell, ActiveCell.End(xlDown))
MyRg.Select
Selection.Sort Key1:=MyRg, Order1:=xlAscending
For Each Cell2Comp In MyRg
Cell2Comp.Select
If Cell2Comp = "" Then GoTo NxtCell
IniTxt = Cell2Comp.Text 'Assign text to test
LenIniTxt = Len(IniTxt) 'get length so that
'we can compare ie. Text - any Numbers
For x = 1 To MyRg.Count - 1
CmpTxt = Cell2Comp.Offset(x, 0) 'Next String to compare against
'check for partial match
If IniTxt = Left(CmpTxt, LenIniTxt) Then
If IniTxt = Cell2Comp.Text Then
ActiveCell.Offset(1, 0).Select
ActiveCell.Clear
End If
Else
If x < MyRg.Count Then
x = x + 1
End If
End If
Next x
NxtCell:
Next Cell2Comp
End Sub
Thanks for your help worked like a charm!