how to add
I have a question on this userform. It now loads nicely. Thanks. Is there a way to add a choice called all to the end of the list? That way the user can select which name to print or select all. In the case of all I need to print all the sheets. That way it is a simple if/then. if one is selected print that one if all is selected I will have to capture that. tnx, Private Sub UserForm_Initialize() 'Dim intLastRow As Integer Dim ws As Worksheet Dim c As Range 'Dim rng As Range Set ws = ThisWorkbook.Worksheets("patients") intLastRow = Cells.Find(What:="*", After:=ws.Range("A1"), SearchDirection:=xlPrevious).Row Set rng = Worksheets("patients").Range("A1:A" & intLastRow) Me.ComboBox2.Clear For Each c In g_rng Me.ComboBox2.AddItem c.Value Next c End Sub I took a leap of faith and added Me.ComboBox2.Additem "All" right under the Me.ComboBox2.Additem c.Value line. What I got was a list interpersed with "all" instead of only once. thanks again, |
how to add
Add it after you've added the other stuff.
For Each c In g_rng Me.ComboBox2.AddItem c.Value Next c me.combobox2.additem "All" Just curious. Did you read the reply I gave at your initial post. Excel-Programming wrote: I have a question on this userform. It now loads nicely. Thanks. Is there a way to add a choice called all to the end of the list? That way the user can select which name to print or select all. In the case of all I need to print all the sheets. That way it is a simple if/then. if one is selected print that one if all is selected I will have to capture that. tnx, Private Sub UserForm_Initialize() 'Dim intLastRow As Integer Dim ws As Worksheet Dim c As Range 'Dim rng As Range Set ws = ThisWorkbook.Worksheets("patients") intLastRow = Cells.Find(What:="*", After:=ws.Range("A1"), SearchDirection:=xlPrevious).Row Set rng = Worksheets("patients").Range("A1:A" & intLastRow) Me.ComboBox2.Clear For Each c In g_rng Me.ComboBox2.AddItem c.Value Next c End Sub I took a leap of faith and added Me.ComboBox2.Additem "All" right under the Me.ComboBox2.Additem c.Value line. What I got was a list interpersed with "all" instead of only once. thanks again, -- Dave Peterson |
All times are GMT +1. The time now is 02:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com