How to add select sheets to a ListBox based on cell value within all sheets of the workbook

maraudingjim

New Member
Joined
Aug 6, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Very new to VBA so bear with me...

Here is what I have.

I'm creating a project where sheet 1 is searchable for specific data based on text. Each line has a checkbox that is linked to a cell on the applicable sheet that the data corresponds to in the workbook. I'd like to be able to populate the ListBox with only the sheets that have been selected via checkbox in worksheet 1 to allow me to quickly print those selected sheets. I attempted to use an If statement that linked linked to the cell in each worksheet that the checkbox changes from TRUE to FALSE, but none of those worked and I either returned all the sheet names or none.

1628263104060.png
1628263132554.png


I found in other forums how to populate all of the sheet names and print those selected from the ListBox, but I haven't been able to establish a way to conditionally select the sheets.

Here is the code I'm using.

Private Sub Worksheet_Activate()
Dim Sh

Me.ListBoxSh.Clear

For Each Sh In ThisWorkbook.Sheets
Me.ListBoxSh.AddItem Sh.Name
Next Sh

End Sub


Nothing seems to be working and my last foray into programming happened in 1999 with C++ at college. Any help would be greatly appreciated.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top