Sorting Problems

jsartain

New Member
Joined
Mar 24, 2002
Messages
24
I am currently using the following code to sort data in a spreadsheet. Numbers appear in these cells if certain criteria is met in the spreadsheet (i.e. 1 for E1, 2 for E2, and nothing if the criteria is met).

Worksheets("Sheet1").Range("E1:E11").Sort _
Key1:=Worksheets("Sheet1").Range("E1")

This data is always being sorted using code from Userforms to determine what data needs to be incorporated in other userforms. The code works fine until I protect the sheet. For some reason it locks cells E1 to E11. I have tried to unlock the cells via code before and after the sorting, but it still is unable to sort. Any ideas?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Don't ask me why, but for some reason. You need to have an active cell to perform some of this stuff via code.
If removing protection does not solve your problem and you are getting a Method of Range type error then add this at the beginning of your code
sheet1.range("A1").select
or any other cell for that matter.
Make sure it is selectable.
Tom
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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