Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old March 15th 21, 09:55 AM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
First recorded activity by ExcelBanter: Mar 2021
Posts: 1
Default How hide all Columns based on specific cell data

I want to hide all the columns of a Spreadsheet based on specific data on a cell.
For example, if B1=0 and E1=0, hide column B and E.
Can anyone help about the easiest way to do it in Excel ?





  #2   Report Post  
Old March 20th 21, 07:56 AM posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
First recorded activity by ExcelBanter: Oct 2003
Posts: 535
Default How hide all Columns based on specific cell data

Dilip Ghosh wrote:

I want to hide all the columns of a Spreadsheet based on specific data
on a cell.
For example, if B1=0 and E1=0, hide column B and E.
Can anyone help about the easiest way to do it in Excel ?


Has to be done in VBA. It's easy if the cells to be checked are in the same
row:

Const rowChk = 1
For c = 1 To ActiveCell.SpecialCells(xlCellTypeLastCell).Column
If Cells(rowChk, c).Value = 0 Then Cells(1, c).EntireColumn.Hidden = True
Next c

(Edit rowChk to the row number to check, of course.)

If the cells aren't in the same row, or are otherwise non-contiguous in any
way, and aren't very numerous, you could use an array:

chk = Array("A1", "B2", "C4")
For c = 0 To UBound(chk)
If Range(chk(c)).Value = 0 Then Range(chk(c)).EntireColumn.Hidden = True
Next c

You could do it other ways, too:

For Each c In Range("A11,C2:E9")
If c.Value = 0 Then c.EntireColumn.Hidden = True
Next

--
A resignation is not a negotiable document.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide Columns based on a cell value Tami Excel Worksheet Functions 10 July 16th 09 06:31 PM
SHow Hide COlumns based on cell value Walt H Excel Programming 4 June 13th 08 04:43 PM
Hide columns based on related cell Lisa Excel Programming 4 May 30th 08 03:23 AM
Hide columns if specific cell is blank? [email protected] Excel Discussion (Misc queries) 0 May 21st 08 05:29 PM
Hide or Unhide certain columns based on a cell value [email protected] Excel Programming 1 July 10th 06 10:17 AM


All times are GMT +1. The time now is 11:47 AM.

Powered by vBulletin® Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright 2004-2021 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"

 

Copyright © 2017