vba to sort on existing code

jmazorra

Well-known Member
Joined
Mar 19, 2011
Messages
715
Hello everyone:

in the code below I am trying to also sort column B2 in ascending order. B1 is the header. I can't seem to make it work.

Any help is appreciated

Code:
 Private Sub CommandButton11_Click()
'copy and paste cells with formulas down
    Dim LR As Long
    For Each SheetName In Array("eeinfo")
        With Worksheets(SheetName)
            LR = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
            .Range("B2:e2").AutoFill Destination:=.Range("B2:e" & LR)
        End With
        
        Next
        
        MsgBox "Step Completed"
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Rich (BB code):
 Private Sub CommandButton11_Click()
'copy and paste cells with formulas down
    Dim LR As Long
    For Each SheetName In Array("eeinfo")
        With Worksheets(SheetName)
            LR = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
            .Range("B2:E" & LR).FillDown
            .Range("B1:E" & LR).Sort .Range("B1"), xlAscending, , , , , , xlYes
        End With
        
        Next
        
        MsgBox "Step Completed"
End Sub
[/QUOTE]
 
Upvote 0

Forum statistics

Threads
1,224,890
Messages
6,181,612
Members
453,057
Latest member
LE102024

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