hello guys..

I have a problem in sorting the excel data in VB..This is example of the data:

PAP03-101-108-01-00-00-00-0000
PAP03-101-108-02-00-00-00-0000
PAP04-101-108-01-01-00-00-0000
PAP04-101-108-02-01-00-00-0000
PAP04-101-108-01-02-00-00-0000

When i try to sort the data, the result is:

PAP03-101-108-01-00-00-00-0000
PAP03-101-108-02-00-00-00-0000
PAP04-101-108-01-01-00-00-0000
PAP04-101-108-01-02-00-00-0000
PAP04-101-108-02-01-00-00-0000

Actually, Im trying to sort it to be in this way :

PAP03-101-108-01-00-00-00-0000
PAP04-101-108-01-01-00-00-0000
PAP04-101-108-01-02-00-00-0000
PAP03-101-108-02-00-00-00-0000
PAP04-101-108-02-01-00-00-0000

I donno how to do it.. I try to use macro code, but nothing happened.
VB Code:
  1. Dim tmp1, tmp2 As String
  2.  
  3.      tmp1 = "B2"
  4.      tmp2 = "D" & n
  5.      objExcel.Range("tmp1:tmp2").Select
  6.      objExcel.Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("D2") _
  7.         , Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
  8.         False, Orientation:=xlTopToBottom

help me guyz!