PC Review


Reply
Thread Tools Rate Thread

How can I enable a macro to run in a hidden worksheet?

 
 
curtc
Guest
Posts: n/a
 
      14th Jul 2009
It presently runs only when unhidden. Conversely, If I could protect the
worksheet from user changes (but still allow the macro to operate in this
individual worksheet) it would accomplish the same goal. The macro sorts data
independently in each column. The name of the sheet is "sort".
Thank You.
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      14th Jul 2009
Unhide the sheet! This may give you some ideas of how ot get started:
http://excel.tips.net/Pages/T002548_...orksheets.html

http://www.teachexcel.com/macros/del...worksheets.php

http://stackoverflow.com/questions/8...s-or-workbooks


HTH,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"curtc" wrote:

> It presently runs only when unhidden. Conversely, If I could protect the
> worksheet from user changes (but still allow the macro to operate in this
> individual worksheet) it would accomplish the same goal. The macro sorts data
> independently in each column. The name of the sheet is "sort".
> Thank You.

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      14th Jul 2009
My bet is that you're selecting ranges on that hidden sheet. And you can only
select a range if that sheet is active. And those hidden sheets will never be
active.

So you could save where the user is, unhide the sheet, select the sheet, select
the range to sort, hide the sheet, and go back to where the user started.

And if you hide your actions with:
application.screenupdating = false
'lots of code here
application.screenupdating = true

But better is to drop the .select's from your code.

Dim RngToSort as range

with worksheets("sort")
'this sorts Column A:X from row 1 to the last row used in column A
'you didn't share what you were sorting!
set rngtosort = .range("A1:X" & .cells(.rows.count,"A").end(xlup).row)
end with

with rngtosort
.Cells.Sort key1:=.Columns(1), Order1:=xlDescending, _
Key2:=.Columns(3), Order2:=xlAscending, _
Header:=xlNo, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
End With
'this sorted by column 1 (descending) and then column 3 (ascending).
'you didn't share how you were sorting!



curtc wrote:
>
> It presently runs only when unhidden. Conversely, If I could protect the
> worksheet from user changes (but still allow the macro to operate in this
> individual worksheet) it would accomplish the same goal. The macro sorts data
> independently in each column. The name of the sheet is "sort".
> Thank You.


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro won't run correctly when a worksheet is hidden ssgcmwatson Microsoft Excel Discussion 0 20th Jul 2010 07:02 AM
Macro to Copy hidden worksheet to new worksheet SueDot Microsoft Excel Programming 4 14th Jul 2009 11:01 PM
Macro needs data from hidden worksheet guillaume.trefeu@web.de Microsoft Excel Programming 4 8th Sep 2006 06:52 AM
macro to hidden worksheet murph306 Microsoft Excel Misc 8 1st Jun 2006 02:35 PM
Using macro with hidden worksheet Jack77 Microsoft Excel Programming 5 30th Mar 2004 01:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:09 PM.