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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

tmcfadden

Board Regular
Joined
Aug 17, 2005
Messages
151
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
 

Forum statistics

Threads
1,136,272
Messages
5,674,748
Members
419,525
Latest member
helensesc

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
Top