View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
crazybass2 crazybass2 is offline
external usenet poster
 
Posts: 167
Default Unhide Columns in certain range

Desert,

Given your note about the general module, I have the following modification
to ensure this macro always works. Having the code snippet in the general
module will use the range ("D3:BD3") on the active sheet. If for any reason
"Sheet6" is not active, this code will not unhide the columns on sheet6. To
correct this you need to add 'Sheets("Sheet6"). before "Range" and "Columns"
So the revised code will be as follows:

Sub aTest()
Dim rng As Range
For Each rng in Sheets("Sheet6").Range("D3:BD3")
If rng < "" Then Sheets("Sheet6").Columns(rng.Column).Hidden = False
Next rng
'The rest of your code goes here
End Sub

That should work regardless of which sheet is active.

Mike
"Desert Piranha" wrote:


crazybass2 Wrote:
Desert,

From you initial post I thought you wanted this action to occur when
data
was pasted into the cells. It appears now that you what this action to
occur
only when "aTest()" is run. The code is basically the same, but you
need to
remove the intersect statement.

Assuming that "aTest()" is in the Sheet module for the sheet in
question....

Sub aTest()
Dim rng As Range
For Each rng in Range("D3:BD3")
If rng < "" Then Columns(rng.Column).Hidden = False
Next rng
'The rest of your code goes here
End Sub

That should do it. If "aTest()" is in another module some modification
will
need to be done, let me know where it is and what sheet you are
modifying if
this is the case

MikeHi Mike,


I'm really sorry about the confusion.

It pasted it into my "aTest()" and it is working good, at this point.
I have to go to a meeting but will test some more tonight, but i see no
problems.

"aTest()" is in a general module and is called from another macro in
the same module.
The first Macro is called from a text box on "Sheet6".
The first code copys data from a open workbook then pastes to
"Sheet6".
"aTest()" reformats the area where the paste was done on "Sheet6".

Thank you very much for your knowledge & help.


--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=560574