ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hiding Columns with Merged Cells (https://www.excelbanter.com/excel-programming/386639-hiding-columns-merged-cells.html)

Steve Pollack

Hiding Columns with Merged Cells
 
I would like to include instructions in a macro to hide a column.
Part of the column contains merged cells.
When I record a macro for the process I want, the instructions read:

Columns("D:D").Select
Selection.EntireColumn.Hidden = True

However, when these instructions are incorporated into my macro both columns
D and E (due to the merged cells) are hidden.

Any help would be appreciated.
Thanks.

Jim Cone

Hiding Columns with Merged Cells
 

Unmerge the cells and then hide the column.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Steve Pollack"
wrote in message
I would like to include instructions in a macro to hide a column.
Part of the column contains merged cells.
When I record a macro for the process I want, the instructions read:

Columns("D:D").Select
Selection.EntireColumn.Hidden = True

However, when these instructions are incorporated into my macro both columns
D and E (due to the merged cells) are hidden.

Any help would be appreciated.
Thanks.

Mark Dullingham

Hiding Columns with Merged Cells
 
It is the Select method that is causing you the problem.
Shorten the code by taking out the .Select and it will work fine -

Columns("D:D").EntireColumn.Hidden = True

Hope this helps

Mark


"Steve Pollack" wrote:

I would like to include instructions in a macro to hide a column.
Part of the column contains merged cells.
When I record a macro for the process I want, the instructions read:

Columns("D:D").Select
Selection.EntireColumn.Hidden = True

However, when these instructions are incorporated into my macro both columns
D and E (due to the merged cells) are hidden.

Any help would be appreciated.
Thanks.


Randy

Hiding Columns with Merged Cells
 
Mark,

I've taken your advice about the .Select but am still having problems.
Below is a snippet of my code. Please advise if there is anything I can do
to correct this.

Thanks!

Randy

Select Case ProjectSize
Case Is = "s"
Columns("G:H").EntireColumn.Hidden = True

"Mark Dullingham" wrote:

It is the Select method that is causing you the problem.
Shorten the code by taking out the .Select and it will work fine -

Columns("D:D").EntireColumn.Hidden = True

Hope this helps

Mark


"Steve Pollack" wrote:

I would like to include instructions in a macro to hide a column.
Part of the column contains merged cells.
When I record a macro for the process I want, the instructions read:

Columns("D:D").Select
Selection.EntireColumn.Hidden = True

However, when these instructions are incorporated into my macro both columns
D and E (due to the merged cells) are hidden.

Any help would be appreciated.
Thanks.



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

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