![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 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? |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|