P
Pam Cheek
I have a table which has been sorted by office symbols,
in column 1 and then by name in column 2.
I have created a user form that allows me to utilize a
combo box to select any given row in the table. I then
have the column information printed in text boxes. This
works for individual rows.
What I need is to have all individuals with the same
office symbol appear in the text box when the office
symbol is selected.
Is there a way to do this?
Code follows:
In the User Form Initialize event:
Private Sub UserForm_Initialize()
Dim MyArrayName() As String
Dim MyArrayOffice() As String
Dim MyArrayProject() As String
RowCount = ActiveDocument.Tables(1).Rows.Count
ColCount = ActiveDocument.Tables(1).Columns.Count
ReDim MyArrayName(RowCount - 1, ColCount - 1)
For i = 1 To RowCount
For j = 1 To ColCount
'Select each cell in the table
Celldata = ActiveDocument.Tables(1).Cell(i, j)
'Remove the paragraph and end-of-cell markers
'as we load the array
MyArrayName(i - 1, j - 1) = Left(Celldata, Len
(Celldata) - 2)
Next
Next
cboSelectResourceName.ColumnCount = ColCount
cboSelectResourceName.List() = MyArrayName()
In a private sub
Private Sub cboSelectResourceName_Change()
Dim MatchFound As String
For x = 0 To cboSelectResourceName.ColumnCount
If cboSelectResourceName.MatchFound = True Then
txtSelectResourceOffice.Text =
cboSelectResourceName.Column(1)
txtSelectResourceProject.Text =
cboSelectResourceName.Column(2)
End If
Next x
End Sub
As I said, it populates the text boxes with just one row
of information, I need all rows that have the same office
symbol.
Thanks for your help.
in column 1 and then by name in column 2.
I have created a user form that allows me to utilize a
combo box to select any given row in the table. I then
have the column information printed in text boxes. This
works for individual rows.
What I need is to have all individuals with the same
office symbol appear in the text box when the office
symbol is selected.
Is there a way to do this?
Code follows:
In the User Form Initialize event:
Private Sub UserForm_Initialize()
Dim MyArrayName() As String
Dim MyArrayOffice() As String
Dim MyArrayProject() As String
RowCount = ActiveDocument.Tables(1).Rows.Count
ColCount = ActiveDocument.Tables(1).Columns.Count
ReDim MyArrayName(RowCount - 1, ColCount - 1)
For i = 1 To RowCount
For j = 1 To ColCount
'Select each cell in the table
Celldata = ActiveDocument.Tables(1).Cell(i, j)
'Remove the paragraph and end-of-cell markers
'as we load the array
MyArrayName(i - 1, j - 1) = Left(Celldata, Len
(Celldata) - 2)
Next
Next
cboSelectResourceName.ColumnCount = ColCount
cboSelectResourceName.List() = MyArrayName()
In a private sub
Private Sub cboSelectResourceName_Change()
Dim MatchFound As String
For x = 0 To cboSelectResourceName.ColumnCount
If cboSelectResourceName.MatchFound = True Then
txtSelectResourceOffice.Text =
cboSelectResourceName.Column(1)
txtSelectResourceProject.Text =
cboSelectResourceName.Column(2)
End If
Next x
End Sub
As I said, it populates the text boxes with just one row
of information, I need all rows that have the same office
symbol.
Thanks for your help.