![]() |
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 |
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 |
All times are GMT +1. The time now is 08:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com