Runtime form based on number of sheets

jjyxk845

Board Regular
Joined
Sep 8, 2006
Messages
89
Ok. Heres what i want to do.

I have a varible number of sheets with varible names.

I want to at runtime produce a form which lists all the sheets and a check box for each one.

this is for my users to select which of there sheets they want to run the macro on.

Can any one point me in the right direction ?

Or is there a better way to do this?

Thanks in advance!

J
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I've got a form with a commandbutton and a listbox. The listbox is set to "ListStyle = 1" and "MultiSelect = 1".

Here's the code:
Code:
Private Sub CommandButton1_Click()
For i = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(i) Then
        Do_something Worksheets(ListBox1.List(i))
    End If
Next i

Unload Me
End Sub

Private Sub UserForm_Activate()
Dim Names() As String
ListBox1.Clear
For Each wrksht In ActiveWorkbook.Worksheets
    ListBox1.AddItem wrksht.Name
Next wrksht

End Sub

Sub Do_something(sheet As Worksheet)

sheet.Unprotect

End Sub

You'll obviously want to change "Do_something" to meet your needs.

-Tim
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,591
Members
449,089
Latest member
Motoracer88

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