P
Pallav Saxena
Hi,
I am trying to sort a worksheet on the basis of the Lot#.
The lot# has values like
1
2
1s
3
2s
4s
4f
10
5
2
5t
I tried this but no luck...
Public Sub SortLotNumber()
'Sort properly
Dim lr As Integer
Dim J As Integer
Dim length As Integer
Dim CellVal As String
Worksheets("Item Data").Activate
lr = GetRealLastRow("Item Data")
For J = 3 To lr
Worksheets("Item Data").Cells(J, 1).Value = "0" &
Worksheets("Item Data").Cells(J, 1).Value & " "
Next J
Rows("3:" & lr).Sort Key1:=Range("A3"),
Order1:=xlAscending, Header:= _
xlNo, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
For J = 3 To lr
length = Len(Worksheets("Item Data").Cells(J,
1).Value)
CellVal = Worksheets("Item Data").Cells(J, 1).Value
Worksheets("Item Data").Cells(J, 1).Value = Left
(Right(CellVal, length - 1), length - 2)
Next J
End Sub
How to do it using vba.. please help....
Regards
Pallav Saxena
I am trying to sort a worksheet on the basis of the Lot#.
The lot# has values like
1
2
1s
3
2s
4s
4f
10
5
2
5t
I tried this but no luck...
Public Sub SortLotNumber()
'Sort properly
Dim lr As Integer
Dim J As Integer
Dim length As Integer
Dim CellVal As String
Worksheets("Item Data").Activate
lr = GetRealLastRow("Item Data")
For J = 3 To lr
Worksheets("Item Data").Cells(J, 1).Value = "0" &
Worksheets("Item Data").Cells(J, 1).Value & " "
Next J
Rows("3:" & lr).Sort Key1:=Range("A3"),
Order1:=xlAscending, Header:= _
xlNo, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
For J = 3 To lr
length = Len(Worksheets("Item Data").Cells(J,
1).Value)
CellVal = Worksheets("Item Data").Cells(J, 1).Value
Worksheets("Item Data").Cells(J, 1).Value = Left
(Right(CellVal, length - 1), length - 2)
Next J
End Sub
How to do it using vba.. please help....
Regards
Pallav Saxena