Microsoft Office Tutorials and References
In Depth Information
Creating a Custom Toolbar
'Last row in column A¶
EndRow = Cells(Rows.Count, 1).End(xlUp).Row¶
'Turn off screen updating¶
Application.ScreenUpdating = False¶
'Store current calculation method in variable¶
OldCalculation = Application.Calculation¶
'Set calculation to manual¶
Application.Calculation = xlCalculationManual¶
'If an error happens, exit nicely¶
On Error GoTo err_h¶
'Loop through each row¶
For i = EndRow To StartRow Step -1¶
Cells(i, 1).EntireRow.Resize(NumRows).Insert¶
Next i¶
'Restore calculation from variable¶
Application.Calculation = OldCalculation¶
'Turn on screen updating¶
Application.ScreenUpdating = True¶
'Does an error message need to display?¶
If Err.Number <> 0 Then¶
MsgBox "Error " & Err.Number & ", " & Err.Description, _¶
End If¶
End Sub¶
Creating a Custom Toolbar
With this procedure, you can create and customize toolbars to facilitate the use
of a custom application.
Example file:
Scenario: When developing an application in Excel, it is
commonly necessary to give the user an interface with which
to interact. Building a toolbar is an easy way to do that
because it is familiar to them and gives the application a
professional look, as well.
This sample shows the best practice for toolbar creation and
use, which is to create the toolbar by code (or on-the-fly)
instead of attaching a manually created toolbar, which often
causes frustration.
Search JabSto ::

Custom Search