Hi,
Below is my code in sheet1 . Sometimes, this is working fine( Disabling "Insert" menu option ). But when I close and reopen the Excel/view another sheet and revisit sheet1 , Run-Time error '5' with "Invalid procedure call or argument" error is popping up at Application.CommandBars block. There is no consistency in the error line . Could some one please help me out on how to fix this issue. Thanks in advance.
Public Sub Worksheet_Activate()
With CommandBars("Worksheet Menu Bar")
.Controls("Insert").Controls("Rows").Enabled = False
.Controls("Insert").Controls("Columns").Enabled = False
End With
With Application.CommandBars("Row")
.Controls("Insert").Enabled = False
End With
With Application.CommandBars("Cell")
.Controls("&Insert...").Enabled = False
End With
End Sub
Private Sub Worksheet_Deactivate()
With CommandBars("Worksheet Menu Bar")
.Controls("Insert").Controls("Rows").Enabled = True
.Controls("Insert").Controls("Columns").Enabled = True
End With
With Application.CommandBars("Row")
.Controls("Insert").Enabled = True
End With
With Application.CommandBars("CELL")
.Controls("&Insert...").Enabled = True
End With
End Sub
Bookmarks