P
Pam
I am still having problems with arrays. I have a table in
my Word document which is 3 columns * 250 rows. I have a
userform which is to populate three fields based on the
information in the table. Field 1 = Name = comes from
column 1 on table; Field 2 = Office Symbol = comes from
column 2 on table; Field 3 = Projects Assigned = comes
from column 3 on table.
I have tried to populate list boxes, text boxes and combo
boxes from three individual arrays. I am just not
familiar enough with the arrays to make them work
properly, any guidance would be greatly appreicated. Code
follows:
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 lod the array
MyArrayName(i - 1, j - 1) = Left(Celldata, Len
(Celldata) - 2)
Next
Next
ComboBox1.ColumnCount = ColCount
ComboBox1.List() = MyArrayName()
RowCount = ActiveDocument.Tables(1).Rows.Count
ColCount = ActiveDocument.Tables(1).Columns.Count
ReDim MyArrayOffice(RowCount - 1, ColCount - 1)
For m = 1 To RowCount
For n = 1 To ColCount
'Select each cell in the table
Celldata = ActiveDocument.Tables(1).Cell(m, n)
'Remove the paragraph and end-of-cell markers
'as we load the array
MyArrayOffice(m - 1, n - 1) = Left(Celldata, Len
(Celldata) - 2)
Next
Next
ListBox1.ColumnCount = ColCount
ListBox1.List() = MyArrayOffice
RowCount = ActiveDocument.Tables(1).Rows.Count
ColCount = ActiveDocument.Tables(1).Columns.Count
ReDim MyArrayProject(RowCount - 1, ColCount - 1)
For o = 1 To RowCount
For p = 1 To ColCount
'Select each cell in the table
Celldata = ActiveDocument.Tables(1).Cell(o, p)
'Remove the paragraph and end-of-cell markers
'as we load the array
MyArrayProject(o - 1, p - 1) = Left(Celldata, Len
(Celldata) - 2)
Next
Next
ListBox2.ColumnCount = ColCount
ListBox2.List() = MyArrayProject
End Sub
HELP!
my Word document which is 3 columns * 250 rows. I have a
userform which is to populate three fields based on the
information in the table. Field 1 = Name = comes from
column 1 on table; Field 2 = Office Symbol = comes from
column 2 on table; Field 3 = Projects Assigned = comes
from column 3 on table.
I have tried to populate list boxes, text boxes and combo
boxes from three individual arrays. I am just not
familiar enough with the arrays to make them work
properly, any guidance would be greatly appreicated. Code
follows:
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 lod the array
MyArrayName(i - 1, j - 1) = Left(Celldata, Len
(Celldata) - 2)
Next
Next
ComboBox1.ColumnCount = ColCount
ComboBox1.List() = MyArrayName()
RowCount = ActiveDocument.Tables(1).Rows.Count
ColCount = ActiveDocument.Tables(1).Columns.Count
ReDim MyArrayOffice(RowCount - 1, ColCount - 1)
For m = 1 To RowCount
For n = 1 To ColCount
'Select each cell in the table
Celldata = ActiveDocument.Tables(1).Cell(m, n)
'Remove the paragraph and end-of-cell markers
'as we load the array
MyArrayOffice(m - 1, n - 1) = Left(Celldata, Len
(Celldata) - 2)
Next
Next
ListBox1.ColumnCount = ColCount
ListBox1.List() = MyArrayOffice
RowCount = ActiveDocument.Tables(1).Rows.Count
ColCount = ActiveDocument.Tables(1).Columns.Count
ReDim MyArrayProject(RowCount - 1, ColCount - 1)
For o = 1 To RowCount
For p = 1 To ColCount
'Select each cell in the table
Celldata = ActiveDocument.Tables(1).Cell(o, p)
'Remove the paragraph and end-of-cell markers
'as we load the array
MyArrayProject(o - 1, p - 1) = Left(Celldata, Len
(Celldata) - 2)
Next
Next
ListBox2.ColumnCount = ColCount
ListBox2.List() = MyArrayProject
End Sub
HELP!