Range of columns

F

fragher75

Hello...
I have that problem (excuse me for my english)..
Why in sheet "me" I can use:

.Range(Columns(15), Columns(17)).Hidden = False

and in another sheets can't I?
I used a For cycle to do it!

For k = 18 To 20
.Columns(k).Hidden = False

Is there another way to hidden a range of columns in another sheets?
How can I hidden that columns(15,16,17 e 21) in another sheets wit
only row of code?
Thanks
Francesco

ToggleButton3.Caption = "Nascondi Previsioni"
With Me
.Range(Columns(15), Columns(17)).Hidden = False
.Range(Columns(6), Columns(7)).Hidden = True
.Columns(22).Hidden = False
.Columns(18).Hidden = True
.ToggleButton4.Visible = True
End With
For i = 4 To 12
For k = 18 To 20
For t = 6 To 8
With Sheets(i)
.Columns(k).Hidden = False
.Columns(t).Hidden = True
.Columns(25).Hidden = False
.ToggleButton2.Visible = True
End With
Next
Next
Nex
 
D

Dave Peterson

You can hide columns on another sheet with something like:

worksheets("sheet99").range("o1:q1,s1").entirecolumn.hidden = true

Columns o:q and s will be hidden.

====
I'm kind of lost with your code, but in general, if you're working with a
different sheet, it's better to fully qualify your ranges:

with worksheets("sheet99")
.Range(.Columns(15), .Columns(17)).Hidden = False
end with

Note the dots in front of .range and both .columns.

If you leave those dots off, then columns(15) will refer to the activesheet (if
the code is in a General module) or it will refer to the sheet owning the
code--if it's in a worksheet module.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top