print each row in the list in the combo bos

J

Janis R

What I really want to know is how to parse the range value in the
case of the "All" selection in the user form? The user form loads
so I will forget about the rowsource. I need to loop through the range
and print each row in the cpyAllPatientsShts() . So it would be a for
each or something see below? I'm not sure how to get the range from
the form into the subscript in the module and print each line.
TNX,
Sub UserForm_Initialize()

Dim lngLastRow As Long
Dim ws As Worksheet
Dim c As Range
Dim rng As Range

Set ws = ThisWorkbook.Worksheets("patients")
lngLastRow = Cells(Rows.Count, "b").End(xlUp).Row


Set rng = ws.Range("C1:C" & lngLastRow)

For Each c In rng.Cells
Me.ComboBox2.AddItem c.Value
Next c

Me.ComboBox2.AddItem "All"
Me.ComboBox2.AddItem "Exit"

End Sub
-----------------------------------

Public Sub cpyAllPatientsShts()
Dim c As Range
Dim i
For Each c In UserForm1.rng
UserForm1.rng
wb.Sheets(2).Copy before:=wb.Sheets(2)
Set ws = wb.Sheets(2)
sStr = UserForm1.g_fNameLName
Lname = Mid(sStr, InStr(1, sStr, " ") + 1)
Next i
End Sub

tHANKS,
 
N

Nigel

You appear to already have a loop that loads the UserForm control ComboBox2
with the range of values required that is stored in rng

Use the same method to read each cell in the range and pass the values to
the print routine, it it not clear to me what your cpyAllPatientsShts()
routine is doing or trying to do?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top