Please refer my attach file.
I want to sort my column 'B' i.e. "Material" ending with text "S" and rest in ascending orders and all the datas according to the order.I have put the VBA codes for that purpose but unable to find the desired result.Desired correction in my vba codes will be helpful to me.
Sorting to Material ending with "S" and rest in ascending
-
- 3StarLounger
- Posts: 354
- Joined: 27 Oct 2013, 15:11
- Location: Gurgaon INDIA
Sorting to Material ending with "S" and rest in ascending
Regards
Pradeep Kumar Gupta
INDIA
Pradeep Kumar Gupta
INDIA
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Sorting to Material ending with "S" and rest in ascendin
Hi Pradeep,PRADEEPB270 wrote:Please refer my attach file.
I want to sort my column 'B' i.e. "Material" ending with text "S" and rest in ascending orders and all the datas according to the order.I have put the VBA codes for that purpose but unable to find the desired result.Desired correction in my vba codes will be helpful to me.
Try this code...
Note: Please ensure the list starts in B5 and also delete the word "Current" in B4. Headings cannot be over two rows. If it is left like this is will cause the macro to not run propely.
Code: Select all
Sub SortList()
Dim rData As Range
Set rData = Range("B5").CurrentRegion
Application.ScreenUpdating = False
rData.Columns(2).EntireColumn.Insert
rData.Columns(2).Cells(1) = "Calc"
rData.Columns(2).Offset(1).FormulaR1C1 = "=RIGHT(RC[-1],1)"
rData.Sort Key1:=rData.Cells(1).Offset(0, 1), Key2:=rData.Cells(1), Header:=xlYes
rData.Columns(2).EntireColumn.Delete
Application.ScreenUpdating = True
End Sub
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- 3StarLounger
- Posts: 354
- Joined: 27 Oct 2013, 15:11
- Location: Gurgaon INDIA
Re: Sorting to Material ending with "S" and rest in ascendin
Macro is working perfect.Thanks Rudi for help.
Regards
Pradeep Kumar Gupta
INDIA
Pradeep Kumar Gupta
INDIA