Forhindring af udskrivning / Avoid print

Disse to VBA subs forhindrer, at det definerede ark bliver printet.

‘Hide the sheet “SheetName” to prevent it from being printed.
Private Sub Workbook_BeforePrint(Cancel As Boolean)

ActiveWorkbook.Worksheets(“SheetName”).Visible = xlSheetVeryHidden

End Sub

‘Unhide the sheet “SheetName” to make it visible and useable.
Private Sub Workbook_SheetActivate(ByVal Sh As Object)

ActiveWorkbook.Worksheets(“SheetName”).Visible = True

End Sub

Excel Statusbar

Statusbar’en i Excel kan styres med VBA kode.
Man kan f.eks. vise relevante meddelelser mens en makro er igang med at behandle data.

Billede af en Excel Statusbar

Sub StatusBar(strMessage As String)

  ' Display the specified message.
  If (strMessage <> "") Then

    ' Ensure that the statusbar is visible.
    Application.DisplayStatusBar = True

    ' Turn off screen updating.
    Application.ScreenUpdating = False

    ' Display the specified text in the statusbar.
    Application.StatusBar = strMessage

  ' No message specified. Clear the statusbar.
  Else

    ' Release control of the statusbar
    Application.StatusBar = False

  End If

End Sub