Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default Hide columns without data

Hello,

Somebody can help me ?

I need a macro that hide all the columns from column C till the last
used column where no data is registrated in recordnr 2.
Remarks..... in record nr.2, in all the columns, a formula is
registrated just looks like
=if(A1="";"";A1).
So, there's no real visible data in some records (only the formula as
mentioned)

regards and thanks,
Johan

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 468
Default Hide columns without data

Paste into a standard module - and make changes (***) to suit.

Sub PrintOnlyColumnsWithValues()
Dim cell As Range
Application.ScreenUpdating = False
With ActiveSheet
For Each cell In .Range("C20:K20") '<<<<***
If cell.Value = 0 Then cell.EntireColumn.Hidden = True
Next
.PrintOut ' Or PrintPreview
.Range("C20:K20").Columns.Hidden = False '<<<<***
End With
Application.ScreenUpdating = True
End Sub

Also, in your Thisworkbook module, paste in:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Application.EnableEvents = False
PrintOnlyColumnsWithValues
Cancel = True
Application.EnableEvents = True
End Sub

HTH

Jim May

"johan" wrote:

Hello,

Somebody can help me ?

I need a macro that hide all the columns from column C till the last
used column where no data is registrated in recordnr 2.
Remarks..... in record nr.2, in all the columns, a formula is
registrated just looks like
=if(A1="";"";A1).
So, there's no real visible data in some records (only the formula as
mentioned)

regards and thanks,
Johan


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 HIDE COLUMNS Excel Discussion (Misc queries) 3 July 5th 07 05:56 AM
Hide/Unhide columns using button on top over relevant columns [email protected] Excel Discussion (Misc queries) 1 March 7th 07 09:24 PM
Hide some columns? Ken New Users to Excel 1 October 26th 06 03:25 AM
Hide Cell Content if no data in previous columns Sherry Excel Discussion (Misc queries) 4 February 21st 05 07:27 PM
Cannot Hide Columns Joe A Excel Discussion (Misc queries) 2 December 15th 04 10:22 PM


All times are GMT +1. The time now is 12:07 AM.

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

About Us

"It's about Microsoft Excel"