// FREE Excel E-book "Record Your First Macro"
→ https://www.launchexcel.com/record-yo...
// Recommended Excel Courses //
1. Launch Excel Macros & VBA School: https://go.launchexcel.com/macros-vba...
2. Excel Campus Elevate Program: https://go.launchexcel.com/excel-camp...
3. My Online Training Hub Dashboards: https://go.launchexcel.com/moth-dashb...
4. Coursera Excel Specialisation: https://go.launchexcel.com/coursera-e...
5. Coursera Everyday Excel: https://go.launchexcel.com/coursera-e...
6. Coursera Excel Data Visualisation: https://go.launchexcel.com/coursera-d...
// Recommended Excel Templates //
If you are looking for pre-built, easy to use spreadsheets, check out Simple Sheets.
https://go.launchexcel.com/simple-she...
They have Excel templates covering cash flow planning, invoices, expense reports, personal budgets, and more!
// Notes //
Here's the code to copy and paste:
------------------------------------------------------------------
Sub Close_All_VBE_Windows() 'CR v5207
'// Source: https://access-programmers.co.uk/foru...
'// Posted: Apr 18, 2017
'// Thanks to: Colin Ridders (https://access-programmers.co.uk/foru...)
'
'// Modified by Victor Chan Dec 15, 2017
'// PURPOSE: Closes all VBE windows except this one
'
'// Note: Needs library 'Microsoft Visual Basic for Applications Extensibility'
'// 1. Click on Tools ... References in the VBE
'// 2. Scroll down and tick the entry for Microsoft Visual Basic for Applications Extensibility 5.3
On Error GoTo Err_Handler
Dim vbWin As VBIDE.Window
For Each vbWin In Application.VBE.Windows
If (vbWin.Type = vbext_wt_CodeWindow Or _
vbWin.Type = vbext_wt_Designer) And _
Not vbWin Is Application.VBE.ActiveWindow Then
vbWin.Close
End If
Next
Exit_Handler:
Exit Sub
Err_Handler:
'CR 02/02/2016 - added error handling to fix issue in 64-bit Office
If Err.Number = 424 Then Resume Next 'object required
MsgBox "Error " & Err.Number & " in Close_All_VBE_Windows procedure: " & Err.Description
Resume Exit_Handler
End Sub
------------------------------------------------------------------
——
// EPISODE NOTES
Please follow these instructions:
▸ Copy and paste the code into a Personal Macro workbook module
▸ Click on Tools ... References in the VBE
▸ Scroll down and tick the entry for Microsoft Visual Basic for Applications Extensibility 5.3
▸ Run the code (F5) and it will close every code window except the active window
——
// REFERENCES
The VBA code was from the following page:
https://access-programmers.co.uk/foru...
Thanks Colin Ridder for sharing!
——
// VISIT MY WEBSITE
For more tutorials on Microsoft Excel and VBA visit the website
→ www.launchexcel.com