Home > OS >  VBA how to insert a variable into this command: Application.ExecuteExcel4Macro "show.toolbar(&q
VBA how to insert a variable into this command: Application.ExecuteExcel4Macro "show.toolbar(&q

Time:08-25

I am trying to hide the toolbar of my excel workbook based on the value of cell B60 which can be either True or False. How can I replace the True in this formula with a variable which contains a cell value?

Sub AdjustSheets()

Dim status_bar As String
status_bar = Range("B59").Value
'Note value in B59 is either True or False

'This hides Menu, how do I replace the "True" with a variable containing a cell reference?'
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"

'This hides Status bar, here I am able to use a variable to replace True or False'
Application.DisplayStatusBar = status_bar

End Sub

CodePudding user response:

To escape variables in VBA you do the following:

" & some_variable & "

CodePudding user response:

@BigBen provided me with the answer

  • Related