ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code not hiding columns (https://www.excelbanter.com/excel-programming/308790-code-not-hiding-columns.html)

Eva Shanley[_2_]

Code not hiding columns
 
I recorded the following code that should hide Col. F in
Sheets 1, 2, and 3. This works fine when I record, but
when I run the code manually Col. F hides on Sheet 1 only,
while the column is merely selected on Sheets 2 & 3. Any
idea what happens here? Thanks in advance!

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Columns("F:F").Select
Selection.EntireColumn.Hidden = True
Sheets("Sheet1").Select
End Sub

Don Guillett[_4_]

Code not hiding columns
 
try
Sub hidecolf()
For Each ws In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
ws.Columns("F:F").EntireColumn.Hidden = True
Next ws
End Sub

--
Don Guillett
SalesAid Software

"Eva Shanley" wrote in message
...
I recorded the following code that should hide Col. F in
Sheets 1, 2, and 3. This works fine when I record, but
when I run the code manually Col. F hides on Sheet 1 only,
while the column is merely selected on Sheets 2 & 3. Any
idea what happens here? Thanks in advance!

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Columns("F:F").Select
Selection.EntireColumn.Hidden = True
Sheets("Sheet1").Select
End Sub




Eva Shanley[_2_]

Code not hiding columns
 
Don,
Thanks for the answer! I understand now why the original
code didn't work.

-----Original Message-----
try
Sub hidecolf()
For Each ws In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
ws.Columns("F:F").EntireColumn.Hidden = True
Next ws
End Sub

--
Don Guillett
SalesAid Software

"Eva Shanley" wrote

in message
...
I recorded the following code that should hide Col. F in
Sheets 1, 2, and 3. This works fine when I record, but
when I run the code manually Col. F hides on Sheet 1

only,
while the column is merely selected on Sheets 2 & 3.

Any
idea what happens here? Thanks in advance!

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Columns("F:F").Select
Selection.EntireColumn.Hidden = True
Sheets("Sheet1").Select
End Sub



.


Don Guillett[_4_]

Code not hiding columns
 
glad to help

--
Don Guillett
SalesAid Software

"Eva Shanley" wrote in message
...
Don,
Thanks for the answer! I understand now why the original
code didn't work.

-----Original Message-----
try
Sub hidecolf()
For Each ws In Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
ws.Columns("F:F").EntireColumn.Hidden = True
Next ws
End Sub

--
Don Guillett
SalesAid Software

"Eva Shanley" wrote

in message
...
I recorded the following code that should hide Col. F in
Sheets 1, 2, and 3. This works fine when I record, but
when I run the code manually Col. F hides on Sheet 1

only,
while the column is merely selected on Sheets 2 & 3.

Any
idea what happens here? Thanks in advance!

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Columns("F:F").Select
Selection.EntireColumn.Hidden = True
Sheets("Sheet1").Select
End Sub



.





All times are GMT +1. The time now is 11:59 PM.

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