Hello, I tried the above macro but for some reason, it still does not adapt to my selection. Here is table I'm trying to sort and the alteration I made
<table border="0" cellpadding="0" cellspacing="0" width="520"><colgroup><col style="mso-width-source:userset;mso-width-alt:1426;width:29pt" width="39"> <col style="mso-width-source:userset;mso-width-alt:3218;width:66pt" width="88"> <col style="mso-width-source:userset;mso-width-alt:5046;width:104pt" width="138"> <col style="mso-width-source:userset;mso-width-alt:3510;width:72pt" width="96"> <col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:3474;width:71pt" width="95"> </colgroup><tbody><tr style="height:15.0pt" height="20"> <td class="xl63" style="height:15.0pt;width:29pt" height="20" width="39">State</td> <td class="xl63" style="width:66pt" width="88">Name</td> <td class="xl63" style="width:104pt" width="138">Last Appraised Value</td> <td class="xl63" style="width:72pt" width="96">SF</td> <td class="xl63" style="width:48pt" width="64">Occ.</td> <td class="xl63" style="width:71pt" width="95">Average Rent.</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">AL</td> <td class="xl67">Property A</td> <td class="xl64">$9,000,000.00 </td> <td class="xl65"> 150,000 </td> <td class="xl66">98%</td> <td class="xl64">$24.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">CA</td> <td class="xl67">Property H</td> <td class="xl64">$12,000,000.00 </td> <td class="xl65"> 178,000 </td> <td class="xl66">90%</td> <td class="xl64">$42.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">CO</td> <td class="xl67">Property I</td> <td class="xl64">$18,000,000.00 </td> <td class="xl65"> 220,000 </td> <td class="xl66">86%</td> <td class="xl64">$28.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">MA</td> <td class="xl67">Property E</td> <td class="xl64">$4,200,000.00 </td> <td class="xl65"> 36,000 </td> <td class="xl66">94%</td> <td class="xl64">$40.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">MI</td> <td class="xl67">Property D</td> <td class="xl64">$8,000,000.00 </td> <td class="xl65"> 120,000 </td> <td class="xl66">86%</td> <td class="xl64">$36.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">NJ</td> <td class="xl67">Property B</td> <td class="xl64">$5,400,000.00 </td> <td class="xl65"> 132,000 </td> <td class="xl66">80%</td> <td class="xl64">$49.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">NJ</td> <td class="xl67">Property G</td> <td class="xl64">$2,000,000.00 </td> <td class="xl65"> 58,000 </td> <td class="xl66">81%</td> <td class="xl64">$39.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">NM</td> <td class="xl67">Property F</td> <td class="xl64">$3,000,000.00 </td> <td class="xl65"> 40,000 </td> <td class="xl66">85%</td> <td class="xl64">$29.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">NY</td> <td class="xl67">Property C</td> <td class="xl64">$6,000,000.00 </td> <td class="xl65"> 85,000 </td> <td class="xl66">82%</td> <td class="xl64">$56.00 </td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt" height="20">WA</td> <td class="xl67">Property J</td> <td class="xl64">$4,000,000.00 </td> <td class="xl65"> 42,000 </td> <td class="xl66">71%</td> <td class="xl64">$45.00 </td> </tr> </tbody></table>
Sub Sor_t()
Dim oneRange As Range
Dim aCell As Range
Set oneRange = Range("A2:F11")
Set aCell = Range("A2")
oneRange.Sort Key1:=aCell, Order1:=xlAscending, Header:=xlYes
End Sub
Basically, in other words, I am trying to replicate the same function carried out by Excel's Sort by Ascending Order function. Bear in mind, its not just going to be a selected group of cells within the column, but also the entire rows that the respective cells are located in.
Therefore, if I were to select the header "Name", and run the macro, the sort order would be ascending according to the names of the properties, at the same time the order for the other columns would also adjust accordingly.
Thanks for your advice.