![]() |
Sorting a column in a different worksheet
I am trying to sort part of a column in a different sheet to the one I
am on. The code i am using is: With Worksheets("sortsheet") ..Unprotect Password:="pwd" ..Range("d3:d100").Sort Key1:=Range("D3"), Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom ..Protect Password:="pwd" End With i keep getting a runtime 1004 error but when i use exactly the same code while the "sortsheet" is active and i'm on that sheet it is fine. What am i doing wrong? Thanks in advance for your help. |
Sorting a column in a different worksheet
Add
Worksheets("sortsheet").activate just before your 'with' -----Original Message----- I am trying to sort part of a column in a different sheet to the one I am on. The code i am using is: With Worksheets("sortsheet") ..Unprotect Password:="pwd" ..Range("d3:d100").Sort Key1:=Range("D3"), Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom ..Protect Password:="pwd" End With i keep getting a runtime 1004 error but when i use exactly the same code while the "sortsheet" is active and i'm on that sheet it is fine. What am i doing wrong? Thanks in advance for your help. . |
All times are GMT +1. The time now is 05:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com