Consulting

Results 1 to 15 of 15

Thread: Vba Code Automatically Sort Large To Small

  1. #1

    Vba Code Automatically Sort Large To Small

    Hi

    I Need Vba Code Automatically Sort Large To Small

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Range("A:A").Sort(xlDescending)
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Thank you SamT
    You can give me full code

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    With the information you posted, that is all I can give.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Contributor GarysStudent's Avatar
    Joined
    Aug 2012
    Location
    Lakehurst, NJ, USA
    Posts
    127
    Location
    Here is an example using event code to automatically sort entries in column A.
    Attached Files Attached Files
    Have a Great Day!

  6. #6
    Thank you
    You can edit Automtically run macro when opening file excel

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim N As Long
        If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
        N = Cells(Rows.Count, "A").End(xlUp).Row
        Range("A1:A" & N).Sort Key1:=Range("A1"), Order1:=xlDescending, Header:=xlYes
    End Sub

  7. #7

    when changing cell A in sheet2 automatically sort cell A in sheet1
    Attached Files Attached Files
    Last edited by etheer; 06-23-2013 at 02:12 PM.

  8. #8
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    Quote Originally Posted by etheer
    Thank you
    You can edit Automtically run macro when opening file excel

    [VBA]Private Sub Worksheet_Change(ByVal Target As Range)
    Dim N As Long
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    N = Cells(Rows.Count, "A").End(xlUp).Row
    Range("A1:A" & N).Sort Key1:=Range("A1"), Order1:=xlDescending, Header:=xlYes
    End Sub
    [/VBA]
    if you want the macro run when the workbook is opened put it in ThisWorkbook code module with Workbook_Open event.

    [VBA]Private Sub Workbook_Open()
    Dim N As Long
    With Worksheets("Sheet1")
    N = .Cells(.Rows.Count, "A").End(xlUp).Row
    .Range("A1:A" & N).Sort Key1:=.Range("A1"), Order1:=xlDescending, Header:=xlYes
    End With
    End Sub
    [/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  9. #9
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    Quote Originally Posted by etheer

    when changing cell A in sheet2 automatically sort cell A in sheet1
    goes to the code module of Sheet2
    [VBA]Private Sub Worksheet_Change(ByVal Target As Range)

    Dim N As Long

    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub

    With Worksheets("Sheet1")
    N = .Cells(.Rows.Count, "A").End(xlUp).Row
    .Range("A1:A" & N).Sort Key1:=.Range("A1"), Order1:=xlDescending, Header:=xlYes
    End With

    End Sub
    [/VBA]
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  10. #10
    I used data online in sheet my problem in code i need click on enter in keyword for work code
    when change cell online dont work code

  11. #11
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    im not sure i can follow you.

    if you run ev_off macro in GarysStudent's file, it will suppress the events. and nothing will happen associated with that event code.

    you have to enable events by running ev_on macro.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  12. #12
    don't work code automatically working when click enter in keyboard

  13. #13
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Quote Originally Posted by etheer
    don't work code automatically working when click enter in keyboard
    Can you be a little more precise in the information that you currently offer?

    Are you entering a value when you click on enter or simply selecting the cell?
    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

  14. #14
    i need when changing cell A in sheet2 automatically sort large to small
    in sheet1
    please download file

    A Sorted Affair2.xlsm



  15. #15
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    That is significantly different from the initial post, which stated "I Need Vba Code Automatically Sort Large To Small" then moved to "when changing cell A in sheet2 automatically sort cell A in sheet1", which is different to "i need when changing cell A in sheet2 automatically sort large to small in sheet1".
    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

Posting Permissions

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