Hide Blank Columns
Closed
Jack
-
Feb 15, 2011 at 02:49 PM
venkat1926
venkat1926
- Posts
- 1864
- Registration date
- Sunday June 14, 2009
- Status
- Contributor
- Last seen
- August 7, 2021
Related:
- Hide Blank Columns
- How to paste data in alternate blank columns in excel - Forum - Excel
- Hide unhide column with clickbox and password ✓ - Forum - Word
- Get macro to detect and hide blank rows ✓ - Forum - Programming
- Excel - Copy a range if the a specific column is blank - How-To - Excel
- Hide Columns ✓ - Forum - Excel
1 reply
venkat1926
Feb 16, 2011 at 01:05 AM
- Posts
- 1864
- Registration date
- Sunday June 14, 2009
- Status
- Contributor
- Last seen
- August 7, 2021
Feb 16, 2011 at 01:05 AM
modified macro is given below
in cells property the first argument is row no. and second argument is column no.
you have reversed
hidden=true is enough.
hidden =false is not necessary
It is a good prctise that in the macro design stage you can have message boxes to check whether macro is ding what you want. once macro is tested you can convert the msgbox statements as comment by putting a single apostrophe in the beginning of the statement.
in cells property the first argument is row no. and second argument is column no.
you have reversed
hidden=true is enough.
hidden =false is not necessary
It is a good prctise that in the macro design stage you can have message boxes to check whether macro is ding what you want. once macro is tested you can convert the msgbox statements as comment by putting a single apostrophe in the beginning of the statement.
Sub HideColumns() Dim begincol As Integer, endcol As Integer, chkrow As Integer Dim colcnt As Integer begincol = 2 endcol = 7 chkrow = 9 For colcnt = begincol To endcol MsgBox colcnt 'If Cells(colcnt, chkrow).Value = "" Then If Cells(chkrow, colcnt) = "" Then Cells(chkrow, colcnt).EntireColumn.Hidden = True 'Cells(colcnt, chkrow).EntireColumn.Hidden = True 'Else 'Cells(colcnt, chkrow).EntireColumn.Hidden = False End If Next colcnt End Sub