Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Entering values into a ListBox.

I am trying to set up a multi-select ListBox on a form that will list all of
the sheets in a workbook. I can get all the sheet names picked up, I just
can't figure out how to place them into the ListBox.
--
I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Entering values into a ListBox.

Like in a userform?

I posted this yesterday:

Instead of using checkboxes, you could use a listbox and make that listbox's
style show checkboxes.

I built a small userform (a listbox and two commandbuttons).

This is the code behind the userform:

Option Explicit
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim iCtr As Long
Dim sCtr As Long
Dim mySheetNames() As String

ReDim mySheetNames(1 To ActiveWorkbook.Sheets.Count)
sCtr = 0
With Me.ListBox1
For iCtr = 1 To .ListCount
If .Selected(iCtr - 1) Then
sCtr = sCtr + 1
mySheetNames(sCtr) = .List(iCtr - 1)
End If
Next iCtr
End With

If iCtr = 0 Then
MsgBox "No Sheets Selected"
Else
ReDim Preserve mySheetNames(1 To sCtr)
Me.Hide
ActiveWorkbook.Sheets(mySheetNames).PrintOut preview:=True
End If

Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long

With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
End With

For iCtr = 1 To ActiveWorkbook.Sheets.Count
If Sheets(iCtr).Visible = xlSheetVisible Then
Me.ListBox1.AddItem Sheets(iCtr).Name
End If
Next iCtr

With Me.CommandButton1
.Caption = "Cancel"
.Cancel = True
End With

With Me.CommandButton2
.Caption = "Ok"
.Default = True
End With

Me.Caption = "Select Sheets to Print"

End Sub

fishonspeed wrote:

I am trying to set up a multi-select ListBox on a form that will list all of
the sheets in a workbook. I can get all the sheet names picked up, I just
can't figure out how to place them into the ListBox.
--
I dispise your poor English and inability to use punctuation correctly ...
or at all.
~FishOnSpeed


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically Entering Values Sanchit Excel Worksheet Functions 4 August 27th 08 03:33 PM
Values Dissappear when entering asiffaleel New Users to Excel 1 May 3rd 06 09:41 AM
Fill values into a listbox matching selected values from a combobox Jon[_19_] Excel Programming 4 January 25th 05 04:25 PM
Compare Listbox values with Collection values Stuart[_5_] Excel Programming 2 September 20th 03 01:58 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"