Le 4 mai 2021, la plateforme Yahoo Questions/Réponses fermera. Elle est désormais accessible en mode lecture seule. Aucune modification ne sera apportée aux autres sites ou services Yahoo, ni à votre compte Yahoo. Vous trouverez plus d’informations sur l'arrêt de Yahoo Questions/Réponses et sur le téléchargement de vos données sur cette page d'aide.
Excel Macro to Hide Column While Printing?
I'm using a macro to hide column F during print operations. Problem is the following macro does not work. If anyone has a better idea or an easier way to hide the column (without physically hiding and unhiding) please let me know.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet
.Range("F1").EntireColumn.Hidden = True
.PrintOut
.Range("F1").EntireColumn.Hidden = False
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
End Sub
This macro should hide column "F" during the print operation then unhide after. I haven't found any help online or from anyone at my office.
Thanks,
3 réponses
- il y a 9 ansRéponse favorite
Your column is hidden properly, but I can see that you use "Application.ScreenUpdating = False" before hiding it.
This command makes your excel screen freeze that's why you don't see the column being hidden.
- IXL@XLLv 7il y a 9 ans
Sorry this involves hiding the column but you only have to do it once.
Create another view of your spreadsheet with the column(s) hidden and use this view to print. Select the old view (with all columns visible) to work on./amend.