PDA

View Full Version : Solved: sort string and match the data



slamet Harto
11-16-2008, 10:25 PM
Hi Guys,

Please help me to find and match the following file attached.

would be glad, if it can solve by the formula or vba.

Many thanks for kind help as always.
Rgds, Harto

slamet Harto
11-16-2008, 11:48 PM
hi guys,
upss sorry, wrong post sample workbook.

Please find attached for your referrence.
Rgds, Harto

georgiboy
11-17-2008, 12:40 AM
What are you using to identify a match, the colour?
Are you entering the rest of installment manualy?

slamet Harto
11-17-2008, 02:03 AM
not the colour, just highligths.
To identify a match, we need to filtering unique value and find the date.
(apologise for confusing the sample wb posted)

Yes, I'm entering the rest of manually as I don't know what formula to approach the result.

Thank you

georgiboy
11-17-2008, 03:02 AM
When you say "find the date" do you mean find the date closest to todays date out of the the multiple customer numbers?

slamet Harto
11-17-2008, 03:07 AM
yes, you are right.

georgiboy
11-17-2008, 04:18 AM
Probably a better approach but this is what i came up with

Sub Identify()
Dim rCell As Range
Dim x As Integer
x = 3

For Each rCell In Range("B3:B" & WorksheetFunction.CountA(Range("B:B")) - 1).Cells

If rCell.Offset(1, 0).Value <> rCell.Value Then
If rCell.Offset(, 2).Value <> "" Then
Range(rCell, rCell.Offset(, 2)).Copy Range("G" & x)
x = x + 1
End If
End If

If rCell.Offset(1, 0).Value = rCell.Value Then
If rCell.Offset(0, 2).Value > rCell.Offset(-1, 2).Value Then
Range(rCell, rCell.Offset(, 2)).Copy Range("G" & x)
End If
End If

Next rCell

Range("G3:I65000").Sort Key1:=Range("G3"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

Range("F3").Value = 1
For Each rCell In Range("F4:F" & Range("F:F").Cells.Count).Cells

If rCell.Offset(, 1).Value <> "" Then
rCell.Value = rCell.Offset(-1, 0).Value + 1
Else
Exit Sub
End If

Hope this helps

slamet Harto
11-17-2008, 11:42 PM
Dear Georgiboy,

It's work well, thank you so much and realy appreciated it.
Now, I'm just thinking to solve the case with excel formula.

Best, Harto