Creating Buttons & Shortcuts
Why Use Buttons?
Keyboard shortcuts are great for you, but what about your colleagues who don't know macros exist? Buttons make macros accessible to everyone!
Benefits:
- User-friendly - Anyone can click a button
- Visual - Clear indication of what each macro does
- Professional - Clean interface for reports and shared files
- Organized - Group related macros together
Creating Your First Button
Let's create a button that runs your FormatTensileTable macro.
Step-by-Step
-
Go to the Developer tab
-
Click Insert → Choose Button (first option under Form Controls)
![Button is the first icon in Form Controls section]
-
Your cursor changes to a crosshair (+)
-
Click and drag on your worksheet to draw the button (anywhere is fine for now)
-
The "Assign Macro" dialogue appears automatically
-
Select
FormatTensileTablefrom the list -
Click OK
-
The button is created with default text "Button 1"
Customize the Button Text
- Right-click the button
- Select Edit Text
- Delete "Button 1" and type:
Format Table - Click outside the button to finish
Test It!
Click your button - it should run the macro instantly!
Button Formatting
Make your buttons look professional:
Change Appearance
- Right-click the button → Format Control
- Font tab:
- Font: Segoe UI or Arial
- Size: 10-11pt
- Style: Regular (bold looks harsh on buttons)
- Click OK
Resize and Position
Resize:
- Click the button to select it
- Drag the corner handles to resize
- Hold Shift while dragging to maintain proportions
Position:
- Drag the button to move it
- Use Excel's gridlines to align with cells
- Position buttons vertically for clarity
Pro tip: Make all related buttons the same width for a clean look!
Creating a Button Panel
Instead of random buttons scattered around, create an organized toolkit panel:
Visual Goal
┌──────────────────────────┐
│ Tensile Analysis │
│ Toolkit │
├──────────────────────────┤
│ 1. Format Table │
│ 2. Calculate Stress │
│ 3. Create Chart │
└──────────────────────────┘
Manual Method (Simple)
- Create 3 buttons using the steps above:
- Button 1 →
FormatTensileTable→ Text: "1. Format Table" - Button 2 →
CalculateStressStrain→ Text: "2. Calculate Stress" -
Button 3 →
CreateStressStrainChart→ Text: "3. Create Chart" -
Align them vertically:
- Stack buttons on top of each other
- Make them the same width (~170 pixels)
-
Leave small gaps between them
-
Add a frame background:
- Insert → Shapes → Rounded Rectangle
- Draw behind your buttons
- Format: Light blue fill, dark blue border
-
Right-click → Send to Back
-
Add a title:
- Insert → Text Box
- Type: "Tensile Analysis Toolkit"
- Format: Bold, 12pt, centered
-
Position above buttons
-
Group everything:
- Select all elements (buttons, frame, title) - Hold Ctrl while clicking each
- Right-click → Group → Group
- Now it moves as one unit!
Automated Method (Advanced)
Want to create professional panels with one click?
Pre-Built Panel Creator
Download Create_Toolkit_Panel.bas and import it.
Then run: CreateTensileToolkitPanel
Result: Professional panel created instantly with:
- Rounded frame with shadow
- Styled title
- 3 aligned buttons
- Everything grouped together
Explore the code to see advanced VBA techniques!
Keyboard Shortcuts
Buttons are great, but shortcuts are faster when you're using the macro.
Setting Shortcuts
During Recording:
- When you click "Record Macro", there's a "Shortcut key" field
- Type a letter (e.g.,
F) - Excel adds
Ctrl+Shift+automatically - Result:
Ctrl+Shift+Fruns the macro
After Recording:
- Developer → Macros (or Alt+F8)
- Select the macro
- Click Options
- Set or change the shortcut key
- Click OK
Good Shortcut Practices
✅ Good Shortcuts:
Ctrl+Shift+F= FormatCtrl+Shift+C= ChartCtrl+Shift+S= Stress calculationCtrl+Shift+B= Batch process
❌ Avoid:
Ctrl+C(already Copy)Ctrl+V(already Paste)Ctrl+S(already Save)Ctrl+Z(already Undo)
Shortcut Conflicts
If you use a shortcut that Excel already uses, your macro takes priority! You'll lose the original function.
Always use Ctrl+Shift+Letter to avoid conflicts.
Quick Access Toolbar
For frequently used macros, add them to the Quick Access Toolbar (top-left corner):
- Click the dropdown arrow on Quick Access Toolbar
- Select More Commands
- In "Choose commands from", select Macros
- Find your macro (e.g.,
FormatTensileTable) - Click Add >>
- Click OK
Result: One-click access from any Excel file!
Button Best Practices
Organization
For simple files:
- 1-3 buttons near related data
- Aligned vertically or horizontally
- Clear, action-oriented text
For complex workbooks:
- Create a dedicated "Controls" area
- Group buttons by workflow
- Use numbered steps (1, 2, 3)
Naming Buttons
❌ Vague:
- "Macro1"
- "Button"
- "Run"
✅ Clear:
- "Format Table"
- "Calculate Stress & Strain"
- "Export to PowerPoint"
Visual Hierarchy
Use formatting to show importance:
- Primary action: Larger button, bold text
- Secondary actions: Standard size
- Dangerous actions: Red text (e.g., "Delete All Data")
Try It Yourself
Button Practice
Create a button panel for your Exercise 1 macro:
Steps:
- Create a button for
FormatSpecimenData - Position it in column G (right of data)
- Format: 150px wide, 30px tall, "Segoe UI" font
- Add a shape behind it (rounded rectangle)
- Add a title text box: "Formatting Tools"
- Group all elements together
Challenge: Can you create 2-3 buttons for future macros you'll make?
What You've Learned
✓ How to create clickable buttons linked to macros
✓ How to format and customize button appearance
✓ How to organize buttons into professional panels
✓ How to set keyboard shortcuts (during and after recording)
✓ How to add macros to Quick Access Toolbar
✓ Best practices for button naming and organization
Next: Real-World Examples
Now that you can record, edit, and create interfaces, let's see powerful real-world macros for material science workflows!
Continue to Real-World Examples →