Lasalle1370
New Member
- Joined
- Aug 7, 2020
- Messages
- 3
- Office Version
- 2019
- Platform
- Windows
There are 2 worksheets in the workbook: sheet1 & sheet2. I have code in sheet2 that will sort sheet1. I want to sort the entire worksheet Sheet1 based on column "A". See the attached image for what Sheet1 looks like.
The code in sheet2 is:
Sub sortWorksheet()
Dim sortrange As Range
Worksheets("Sheet1").Activate
Set sortrange = Range("A:I")
sortrange.Sort key1:=Range("A1"), order1:=xlAscending, Header:=xlYes
End Sub
Nothing happens when I run this code.
What am I missing?
The code in sheet2 is:
Sub sortWorksheet()
Dim sortrange As Range
Worksheets("Sheet1").Activate
Set sortrange = Range("A:I")
sortrange.Sort key1:=Range("A1"), order1:=xlAscending, Header:=xlYes
End Sub
Nothing happens when I run this code.
What am I missing?