ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range of columns (https://www.excelbanter.com/excel-programming/309742-range-columns.html)

fragher75[_2_]

Range of columns
 
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

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

Range of columns
 
You can hide columns on another sheet with something like:

worksheets("sheet99").range("o1:q1,s1").entirecolu mn.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.



"fragher75 <" wrote:

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 with
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
Next

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com