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()