ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically hide unused columns (https://www.excelbanter.com/excel-programming/439042-automatically-hide-unused-columns.html)

jm913

Automatically hide unused columns
 
I have a 10 year schedule which returns values to a defined point. Is there
a way to hide the unused columns with the numerical value i am entering.


As an example If i want to show 60 months of cash flow can i hide the other
60 when i enter this value.
--
Thanks for your help!

Per Jessen

Automatically hide unused columns
 
Hi

You do not say where you want to enter # of month to show, so I used an
inputbox.

Sub HideUnusedCols()
Dim showCF As Long
Dim FirstDataColCell As Range
Dim FirstDataCol As Long
Dim LastDataCol As Long

showCF = InputBox _
("How many month of cash flow do you want to show ?", "Regards, Per")
FirstDataCol = 2 'Titles in column 1
LastDataCol = 121
Set FirstDataColCell = Cells(1, FirstDataCol)
FirstDataColCell.Resize(1, LastDataCol - FirstDataCol + 1) _
.EntireColumn.Hidden = False
If showCF < 120 Then
FirstDataColCell.Resize(1, LastDataCol - showCF - FirstDataCol + 1) _
.EntireColumn.Hidden = True
End If
End Sub

Regards,
Per

"jm913" skrev i meddelelsen
...
I have a 10 year schedule which returns values to a defined point. Is
there
a way to hide the unused columns with the numerical value i am entering.


As an example If i want to show 60 months of cash flow can i hide the
other
60 when i enter this value.
--
Thanks for your help!




All times are GMT +1. The time now is 03:23 AM.

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