N
Noah
I originally posted this question on 11/14, but I still haven't been able to
figure out how to solve the problem based on the response that I got. So I
am posting the question again in more detail.
If Noah is the user, I want the RowSource of ListBox1 in UserForm1 to fill
with values from Sheet1. If Joe is the user, I want the RowSource of
ListBox1 in UserForm1 to fill with values from Sheet2. I am not sure if this
is the right think to do, but I have left the RowSource field in the
Properties of ListBox1 empty.
-----------------------
I currently have the following code in Module1:
Public rng as Range
Sub Macro1()
Dim User As String
User = Environ("UserName")
Select Case User
Case "Noah"
lastrow = Sheet1.Cells(1, 1).End(xlDown).Row
rng = Sheet1.Range(Cells(1, 1), Cells(lastrow, 2))
UserForm1.Show
Case “Joeâ€
lastrow = Sheet2.Cells(1, 1).End(xlDown).Row
rng = Sheet2.Range(Cells(1, 1), Cells(lastrow, 2))
UserForm1.Show
Case Else
End Select
End Sub
-----------------------
I currently have the following code in the code module for UserForm1:
Private Sub UserForm_Initialize()
Me.ListBox1.RowSource = rng.Address
End Sub
figure out how to solve the problem based on the response that I got. So I
am posting the question again in more detail.
If Noah is the user, I want the RowSource of ListBox1 in UserForm1 to fill
with values from Sheet1. If Joe is the user, I want the RowSource of
ListBox1 in UserForm1 to fill with values from Sheet2. I am not sure if this
is the right think to do, but I have left the RowSource field in the
Properties of ListBox1 empty.
-----------------------
I currently have the following code in Module1:
Public rng as Range
Sub Macro1()
Dim User As String
User = Environ("UserName")
Select Case User
Case "Noah"
lastrow = Sheet1.Cells(1, 1).End(xlDown).Row
rng = Sheet1.Range(Cells(1, 1), Cells(lastrow, 2))
UserForm1.Show
Case “Joeâ€
lastrow = Sheet2.Cells(1, 1).End(xlDown).Row
rng = Sheet2.Range(Cells(1, 1), Cells(lastrow, 2))
UserForm1.Show
Case Else
End Select
End Sub
-----------------------
I currently have the following code in the code module for UserForm1:
Private Sub UserForm_Initialize()
Me.ListBox1.RowSource = rng.Address
End Sub