+ Reply to Thread
Results 1 to 3 of 3

sorting

  1. #1
    Registered User
    Join Date
    09-20-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    5

    sorting

    Hey,

    beginner question...

    I have four column on a worksheet, each column is a list of numbers.

    i wish to create a message box, where the user can input the column number and then be able to sort which column he has selected.

    here's what i have so far, it's not working, so i'm going to assume that something's fundamentally wrong...

    Sub userinput()
    MsgBox InputBox("Which exam would you like to sort?", "Sort Exams"), vbInformation, "User's Choice"

    If vbInformation = 1 Then
    Call sorting1
    End If

    If vbInformation = 2 Then
    Call sorting2
    End If

    If vbInformation = 3 Then
    Call sorting3
    End If

    If vbInformation = 4 Then
    Call sorting4
    End If

    End Sub
    Sub sorting1()

    With ActiveWorkbook.Worksheets("sheet1").Sort
    .SetRange range("B4:B18")
    .Apply

    End With

    End Sub

    Sub sorting2()

    range("C4").Sort key1: range ("c4:c18"), order1:=xlDescending, Header:=xlYes, _
    OrderCustom:=1, MatchCase:=False, _
    Orientation:=xlTopToBottom



    End Sub

    Sub sorting3()

    With ActiveWorkbook.Worksheets("sheet1").Sort
    .SetRange range("D4:D18")

    End Sub

    Sub sorting4()

    With ActiveWorkbook.Worksheets("sheet1").Sort
    .SetRange range("E4:E18")

    End Sub

  2. #2
    Registered User
    Join Date
    09-20-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: sorting problem (beginner question)

    i was thinking that ideally the subs of sorting1,2,3,and 4.

    but i was just trying a different set of procedures to see what might work, which apparently is none of them...

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: sorting problem (beginner question)

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1