![]() |
Listbox
I have created a listbox which displays all the sheet
within my workbook. I have added a check box to allow the user to move from one sheet to the other within the listbox. I have also added a check box to allow the user to print the active sheet only. All works well. However, I want to be able to tag whatever sheets that is displayed within the same listbox, using the same print check box and print all the user selected sheets. Can anyone help me out with this function... |
Listbox
Gilbert,
I often use the GetSelected function to retrieve a 1-based 1-dimensional array of the selected items from a listbox. Works on all variants of multiselect Returns an empty variant if no item is selected. Optionally you can specify which column to return (1st column = 0) you can use it like: '--------------------------------------------------------------- Private Sub CommandButton1_Click() Dim s s = GetSelected(Me.Controls("Listbox1")) If Not IsEmpty(s) Then Worksheets(s).Select ActiveWindow.SelectedSheets.PrintOut End If End Sub '--------------------------------------------------------------- Function GetSelected(mylst As MSForms.ListBox, _ Optional colNum As Integer) Dim aRes As Variant Dim i, n As Integer With mylst If .ListCount 0 Then ReDim aRes(1 To .ListCount) For i = 0 To .ListCount - 1 If .Selected(i) Then n = n + 1 aRes(n) = .List(i, colNum) End If Next End If End With If n 0 Then ReDim Preserve aRes(1 To n) GetSelected = aRes End If End Function Suc6! keepITcool < email : keepitcool chello nl (with @ and .) < homepage: http://members.chello.nl/keepitcool "Gilbert Aponte" wrote: I have created a listbox which displays all the sheet within my workbook. I have added a check box to allow the user to move from one sheet to the other within the listbox. I have also added a check box to allow the user to print the active sheet only. All works well. However, I want to be able to tag whatever sheets that is displayed within the same listbox, using the same print check box and print all the user selected sheets. Can anyone help me out with this function... |
All times are GMT +1. The time now is 02:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com