Sorting sheet by column before i open userformadvice

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,934
Office Version
  1. 2007
Platform
  1. Windows
I am trying to sort a sheet by column & then open my userform.
I have the below but i dont see anything happen

SOME INFOR FOR YOU.
Headers on row 6
Row 7 is hidden.
First row of values are at row 8
I wish to sort column D from A-Z

In the code supplied, The line shown in Red im not sure what the value is where i entered 4 as i thought it was the column to sort by ?
See screenshot please

EaseUS_2025_01_30_11_00_23.jpg



Rich (BB code):
Private Sub ConnectorUsed_Click()
    Dim x As Long
        Application.ScreenUpdating = False
        With Sheets("MCLIST")
        If .AutoFilterMode Then .AutoFilterMode = False
        x = .Cells(.Rows.Count, 4).End(xlUp).Row
            .Range("A8:L" & x).Sort Key1:=Range("A8"), Order1:=xlAscending, Header:=xlGuess
    End With

End Sub
 
Try it.
Modify
.Range("A8:L" & x).Sort Key1:=Range("A8"), Order1:=xlAscending, Header:=xlGuess
to
.Range("A8:L" & x).Sort Key1:=Range("D8"), Order1:=xlAscending, Header:=xlNo
 
Upvote 0

Forum statistics

Threads
1,226,827
Messages
6,193,177
Members
453,778
Latest member
RDJones45

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