David77

Board Regular
Joined
Jun 24, 2020
Messages
109
Office Version
  1. 365
Platform
  1. Windows
Hello everybody,



I have the following list of information:






Is there any way in which I can alphabetically order this list with respect to column B? Would greatly appreciate any assistance I can obtain! :)



Thank you very much everybody.



Best regards,

David
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Also, is there a way in which I can get it to sort everything with respect to one column - while ignoring two other columns so they dont sort?
 
Upvote 0
This should do it.
VBA Code:
Function Alphabetize(SHEET as Worksheet, Argument, First_Row, Data_Column)
    ' Returns the Row to put the data into keeping the data alphabetized.
    ' 8/13/20 Created. WML
    
    Prog = "Alphabetize"
    
    LastRow = Last_Row(SHEET)  ' <--  However you do this on your system
    
    If LastRow < First_Row Then
        Alphabetize = First_Row
        SHEET.Cells(First_Row, Data_Column) = Argument
    Else
         For Row = First_Row To LastRow
             To_test = SHEET.Cells(Row, Data_Column)
             If To_test = Argument Then
                 Alphabetize = Row
             ElseIf To_test > Argument Then
                 Call Data_Insert_Rows(SHEET, Row, Row)
                 SHEET.Cells(Row, Data_Column) = Argument
             End If
        Next Row
    
        SHEET.Cells(Row, Data_Column) = Argument
    End If
    
    
End Function ' AlphabetizeSub Data_Insert(SHEET as Worksheet, Row1, Col1, _
                Row2_or_All_or_Minus_1, _
                Col2_or_ALL_or_Minus_1, _
                Insert_Arg As Insert_Types)
    ' Shift Cells
    ' XTRL values: xlDown, xlToRight, xlColumns, xlRows
    ' 10/6/15 Put in All_Rng call. WML
    ' 5/20/20 Reworked to standardize the code WML
    ' 5/30/20 Reworked. WMl
    
    Prog = "Data_Insert"
        
    Row2 = Row2_or_All_or_Minus_1
    Col2 = Col2_or_ALL_or_Minus_1
    
    If Row2 = -1 Or Row2 = "All" Then Row2 = Last_Row(SHEET, Col2)
    If Col2 = -1 Or Col2 = "All" Then Col2 = Last_Col(SHEET, Col2)
    
    If Row2 >= Row1 And Col2 >= Col1 Then
    
        RangeStr = Make_Range(Row1, Col1, Row2, Col2, SHEET)
        
        Select Case Insert_Arg
            Case it_Up
                SHEET.Range(RangeStr).Insert Shift:=xlShift_Up
            Case dsd_Shift_Left
                SHEET.Range(RangeStr).Insert Shift:=xlShiftToLeft
            Case dsd_Entire_Row
                SHEET.Range(RangeStr).EntireRow.Insert
            Case dsd_Entire_Column
                SHEET.Range(RangeStr).EntireColumn.Insert
        End Select
        
    Else
        ' No error message given.  Just did NOT excute any deletion.
    End If

        
End Sub ' Data_Insert


Sub Data_Insert_Rows(SHEET as Worksheet, Row_Start, _
                     Optional Row_End_or_ALL_or_Minus_1 = "")
    ' Insert indicated Rows & returning Start Row.
    ' 12/20/10 Use Sheet_Arg. WML
    ' 1/29/19 Changed "Data_Insert". WML
    ' 7/13/19 Changed "Col2" arg in Data_Insert call to -1. WML
    ' 4/23/20 Changes in "Data_Insert" calls. WML
    ' 6/3/20 Changed so if only 1 row to insert, don't need the second arg. WML
    
    Row_End = Row_End_or_ALL_or_Minus_1
    If Row_End = "" Then Row_End = Row_Start
    
    Call Data_Insert(SHEET, Row_Start, 1, Row_End, -1, it_Entire_Row)
                          
End Sub ' Insert_Data_Rows()
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top