VBA to sort 6 columns only

Trueblue862

Board Regular
Joined
May 24, 2020
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi, I have a spreadsheet that has 6 columns of data in the middle of it I want to sort, C through H, starting at row 3. Is there a way of sorting these with VBA without touching the information to the sides of the sheet? I hope this is clear enough. Any help would be greatly appreciated.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi. Please, see if this code could help you.
VBA Code:
Sub SortColumnsCH()
 Range("C3:H" & Cells(Rows.Count, 3).End(3).Row).Sort Key1:=[C3], Order1:=xlAscending, Header:=xlNo, DataOption1:=xlSortTextAsNumbers
End Sub
 
Upvote 0
Thank you, I’ll give it a try as soon as I get back to my computer.
 
Upvote 0
Hi, sorry for the late reply. I'm getting a run-time error '1004', sort method of range class failed.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,720
Members
448,986
Latest member
andreguerra

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