ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   hiding columns (https://www.excelbanter.com/excel-discussion-misc-queries/98832-hiding-columns.html)

[email protected]

hiding columns
 
I am hoping someone can help me out with this. I have set up a
spreadsheet to help manage projects around the company. There is an
input worksheet and I would like to hide columns that will not be used
in the project. For example, if the category A01 will not have any
funds applied to it, I would like to hide that column. Is there any
way to do this without having to do it manually?

If you need more information let me know and I can try to explain it
better.


JLatham

hiding columns
 
One way would be for you to simply record the actions you take under various
project conditions and have them available for future use.

Plan ahead a little so your macros don't include too many extra unneeded
steps, but as long as the end result is what you want, that's ok also.

Just use Tools | Macro | Record New Macro
give each one a meaningful name such as "HideForTypeXProjects" and be sure
and choose the [Store Macro in] option of Personal Macro Workbook. That will
keep the macros on your machine so they are always available to you and won't
get distributed with the .xls files you distribute.

You can record all of the keystrokes necessary to set up an entire workbook
at once, including selecting sheets, columns, hiding them, etc.
" wrote:

I am hoping someone can help me out with this. I have set up a
spreadsheet to help manage projects around the company. There is an
input worksheet and I would like to hide columns that will not be used
in the project. For example, if the category A01 will not have any
funds applied to it, I would like to hide that column. Is there any
way to do this without having to do it manually?

If you need more information let me know and I can try to explain it
better.



[email protected]

hiding columns
 
Thanks for the information. The only problem is that you can't predict
which categories will be used on each project.


Dave Peterson

hiding columns
 
So you have a worksheet with categories laid out across the top (say row 1) and
maybe some description in column A?

You could put a couple of buttons from the Forms toolbar on the worksheet that
run macros to hide/show the columns.

I'd resize row 1 and column A to fit both buttons (so that they're always
visible).

Then assign the buttons to one of these macros:

Option Explicit
Sub HideCols()

Dim iCol As Long
Dim LastCol As Long

Application.ScreenUpdating = False
With ActiveSheet
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
For iCol = 2 To LastCol
If Application.Sum(.Columns(iCol)) = 0 Then
'hide the column
.Columns(iCol).Hidden = True
Else
.Columns(iCol).Hidden = False
End If
Next iCol
End With
Application.ScreenUpdating = True

End Sub
Sub ShowCols()
With ActiveSheet
.Columns.Hidden = False
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm



wrote:

I am hoping someone can help me out with this. I have set up a
spreadsheet to help manage projects around the company. There is an
input worksheet and I would like to hide columns that will not be used
in the project. For example, if the category A01 will not have any
funds applied to it, I would like to hide that column. Is there any
way to do this without having to do it manually?

If you need more information let me know and I can try to explain it
better.


--

Dave Peterson


All times are GMT +1. The time now is 03:31 PM.

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