#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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



All times are GMT +1. The time now is 01:06 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"