Consulting

Results 1 to 19 of 19

Thread: Vba Code Automatically Sort Rows Large To Small

  1. #1

    Vba Code Automatically Sort Rows Large To Small

    I Need Help Vba Code Automatically Sort Rows Large To Small By Data In Column D
    Attached Files Attached Files

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    First record a macro of you manually doing the sort, then post the macro code here do we can help you clean it up and refine it.

  3. #3
    you download book1s.xlsx

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    I did.

    You record macro

  5. #5
    Hi SamT
    i have this macro you can edit it
    this macro skip cells 0
    i need also sort data large to small
    i hope you can help me


    [VBA]Private Sub Hide_Unhide()
    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    For i = 7 To 111
    Rows(i).Hidden = (Cells(i, "J").Value = 0) + (Cells(i, "b").Value = "")
    Next i
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub[/VBA]
    Last edited by Aussiebear; 03-19-2013 at 03:27 PM. Reason: Added the correct tags to the supplied code

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    What is the range of the entire table you need sorted?
    Example Answer: A7 to J111

  7. #7
    Sort Large To Small By Data In Column D

  8. #8
    [VBA]Private Sub Hide_Unhide()
    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    For i = 4 To 500
    Rows(i).Hidden = (Cells(i, "D").Value = 0) + (Cells(i, "F").Value = "")
    Next i
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub[/VBA]
    Attached Files Attached Files
    Last edited by Aussiebear; 03-19-2013 at 03:28 PM. Reason: Added the correct tags to the supplied code

  9. #9
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Sort what?
    What is the range of the entire table you need sorted?
    Example Answer: A7 to J111

  10. #10
    Quote Originally Posted by SamT
    Sort what?
    Samt please download book1macro

    I need Sort data in column D large to small

  11. #11
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    [VBA]
    Range("A3111").Sort.( _
    Key1:=Range("D3"), _
    Order1:= xlDescending, _
    Header:= xlNo)


    [/VBA]

  12. #12
    is impossible sort data in column D ?
    Last edited by etheer; 03-18-2013 at 04:46 PM.

  13. #13
    Quote Originally Posted by SamT
    [vba]
    Range("A3111").Sort.( _
    Key1:=Range("D3"), _
    Order1:= xlDescending, _
    Header:= xlNo)


    [/vba]
    thank you SamT
    you can edit book1macro.xlsx and upload it agian
    plases

  14. #14
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    [vba]Range("D").Sort.( _
    Key1:=Range("D1"), _
    Order1:= xlDescending, _
    Header:= xlGuess) [/vba]

  15. #15
    Quote Originally Posted by SamT
    [vba]Range("D").Sort.( _
    Key1:=Range("D1"), _
    Order1:= xlDescending, _
    Header:= xlGuess) [/vba]
    how use this code in book1macro.xlsm ?

  16. #16
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    You need to start using the help files. In VBA, put the cursor in a word you want help on and press F1.

    You might get better help by using the Non English Help Forum.


    [vba]Private Sub Hide_Unhide()
    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    For i = 4 To 500
    Rows(i).Hidden = (Cells(i, "D").Value = 0) + (Cells(i, "F").Value = "")
    Next i

    'Sorting only one column of a table will mess up the table.
    'Change "D" to refelect the entire table.
    Range("D").Sort _
    Key1:=Range("D1"), _
    Order1:=xlDescending, _
    Header:=xlGuess

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub
    [/vba]

  17. #17
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    There's a couple of good points that arise out of this thread that need to be made.

    Firstly, simply by demanding that others download a workbook from the forum to solve an issue is not good ethics. There's a risk involved when downloading and opening a workbook from someone you don't know or yet trust.

    Secondly, the underlying concept of the forum is to assist others to learn the VBA language and its usage, through both the offerings of sections of code, and or the request to supply a section of code that has been self produced.

    Thirdly, all offers to assist are done by volunteers who give freely of their time. So to make the most of these offers, one needs to be prepared to make the issue as clear as possible by definition. Provide workbooks with working samples of data and provide examples of what has been tried. Then those wanting to assist are in a better position to work on a solution.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  18. #18
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Thank you, mod.

  19. #19
    Quote Originally Posted by SamT
    You need to start using the help files. In VBA, put the cursor in a word you want help on and press F1.

    You might get better help by using the Non English Help Forum.


    [vba]Private Sub Hide_Unhide()
    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    For i = 4 To 500
    Rows(i).Hidden = (Cells(i, "D").Value = 0) + (Cells(i, "F").Value = "")
    Next i

    'Sorting only one column of a table will mess up the table.
    'Change "D" to refelect the entire table.
    Range("D").Sort _
    Key1:=Range("D1"), _
    Order1:=xlDescending, _
    Header:=xlGuess

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    End Sub
    [/vba]

    Thank you so much SamT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •