I have written the current VBA code below to sort each column alphabetically. I need to alter this code so that it sorts in the following order: 1. Alphabetically 2. Numerically 3. By Symbols
The current VBA code sorts by 1. Numbers 2. Symbols. and then alphabetically.
The current code is as follows:![]()
Sub SortColumnsAlphabetically() Dim ws As Worksheet Dim rng As Range Dim lastRow As Long Dim lastCol As Long Dim col As Long ' Define the worksheet (change "Data List" to your actual sheet name) Set ws = ThisWorkbook.Sheets("Data List") ' Define the range (A3:E27 in this case) Set rng = ws.Range("A3:E27") ' Find the last row and last column in the range lastRow = rng.Rows.Count + rng.Row - 1 lastCol = rng.Columns.Count + rng.Column - 1 ' Loop through each column and sort it alphabetically For col = rng.Column To lastCol ws.Range(ws.Cells(rng.Row, col), ws.Cells(lastRow, col)).Sort _ Key1:=ws.Cells(rng.Row, col), _ Order1:=xlAscending, _ Header:=xlNo Next col End Sub











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks