Sort a worksheet

Computerman

Board Regular
Joined
Mar 3, 2016
Messages
91
I have a worksheet with columns A through R. I need to sort this worksheet by the value that is in Column C. I have searched for the answer and have tried several suggestions, but the worksheet never sorts. In my code below I have commented out all the things I have tried. Is what I am trying to do possible, and if so, how?

Code:
Private Sub cmdBuildOrders_Click()
cmdBuildOrders.Caption = "Running"
cmdBuildOrders.BackColor = RGB(255, 255, 0)
cmdBuildOrders.ForeColor = RGB(0, 0, 0)
Application.Wait (Now + TimeValue("0:00:01")) 'allows command button to change text and back color

lastrow = Sheet3.Range("A100").End(xlUp).Row

Sheet3.Activate
'Range("C1:C17", Range("C1").End(xlDown)).Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes

'ActiveSheet.Sort.SortFields.Clear
'Columns("A:R").Sort Key1:=Range("C2:C17"), Order1:=xlAscending, Header:=xlYes

'Range("A2:R17").Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes

'Range("C2").CurrentRegion.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlYes

'LastRowSort = Sheet3.Cells(Rows.Count, 2).End(xlUp).Row
'Range("A2:R" & LastRowSort).Sort key1:=Range("C2:C" & LastRowSort), _
   order1:=xlAscending, Header:=xlNo


'For Row = 2 To LastRow
'    Sheet4.Cells(Row, 2).Value = "MPS"                             'Customer Code Parent Row
'    Sheet4.Cells(Row, 3).Value = "ATNA"                           'Project Code Parent Row
'    Sheet4.Cells(Row, 5).Value = "Standard"                     'Type Parent Row
'    Sheet4.Cells(Row, 6).Value = "Pick Pack and Ship"    'Attribute Parent Row
'    Sheet4.Cells(Row, 13).Value = "False"                         'IsAccessory Child Row
'    Sheet4.Cells(Row, 14).Value = "False"                         'IsConfiguration Child Row
'    Sheet4.Cells(Row, 15).Value = "False"                         'Reservation Parent Row
'
'Next Row
cmdBuildOrders.Caption = "Build Customer Page"
cmdBuildOrders.BackColor = RGB(0, 176, 80)
cmdBuildOrders.ForeColor = RGB(255, 255, 255)
End Sub

Computerman
 
Glad we could help & thanks for the feedback
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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