VBA & Macro Problems

Remove the Selected Tab from an Excel VBA TabStrip

Ayan MasoodAyan Masood Nov 22, 2026 869 views

Question details

Remove the currently selected tab from an ActiveX TabStrip with VBA and optionally activate another tab.

Remove the Selected Tab from an Excel VBA TabStrip
Product
Microsoft Excel VBA ActiveX TabStrip
Device & OS
not provided
Scenario
A workbook uses a TabStrip control, and the user wants a macro to delete its selected tab.
Observed behavior
The selected tab is removed, and another tab can be activated if any tabs remain.
Before you start

Confirm that the control is an ActiveX TabStrip named TabStrip1 on the active worksheet. Check that your Excel installation permits macros and ActiveX controls under its security settings.

Solution 1Recommended

Remove the selected worksheet TabStrip tab with VBA

Use the selected tab's index with Tabs.Remove, then optionally select a remaining tab.

1
Open the VBA editor

In Excel, open the workbook and press Alt+F11. Select Insert > Module to add a standard VBA module.

2
Add the removal macro

Paste this code into the module: Sub RemoveSelectedTab() Dim Ts As Object Set Ts = ActiveSheet.OLEObjects("TabStrip1").Object If Ts.Tabs.Count > 0 Then Ts.Tabs.Remove Ts.SelectedItem.Index If Ts.Tabs.Count > 0 Then Ts.Value = 0 End If End Sub

3
Run the macro

Return to Excel, select the worksheet containing TabStrip1, and select the tab to remove. Press Alt+F8, choose RemoveSelectedTab, and click Run.

Remove the selected worksheet TabStrip tab with VBA
TabStrip and control visibility: The macro selects the first remaining tab. A TabStrip does not automatically show or hide other objects; use separate VBA code to manage their visibility.
Free Microsoft Office alternative

Work with Excel spreadsheets in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move everyday spreadsheet work. It does not fix Excel ActiveX or VBA issues, so verify any macro-dependent workbook before migrating.

Open and edit Excel .xlsx spreadsheetsUse a familiar spreadsheet interface for everyday workbook tasksWork with tabs and sheets in a lightweight Office suiteGet started for free
microsoft office alternative - wps office

Frequently Asked Questions

How do I remove the selected tab without activating another one explicitly?

Call Ts.Tabs.Remove Ts.SelectedItem.Index and omit the line that assigns Ts.Value. Check Ts.Tabs.Count first so the removal runs only when a tab exists.

How do I add a tab to the TabStrip?

After obtaining the control as Ts, use Ts.Tabs.Add in your VBA procedure to add a tab.

Can I use this approach with a UserForm TabStrip?

Yes. In code within the UserForm, refer to the control with Me.TabStrip1 instead of ActiveSheet.OLEObjects("TabStrip1").Object, then use the same Tabs.Remove call.

Will deleting a TabStrip tab hide its associated controls?

No. A TabStrip does not automatically manage other controls. Add VBA that changes those controls' Visible properties when the selected tab changes or is removed.