Can you get the value range for a particular column?

M

Maria

I want to get all the values that appear in a particular resource field in a
plan. Right now i have hard coded all the values into an array, but i was
hoping that there is a way to get the range of values into an array
automatically.
I really don't want to go through all the resources and check if the value
is already in the array or not, but if this is the only way that is my only
option right now.
Is there a method or a quick way to get this range without looping through
the resources.

Thanks,

Maria
 
J

JackD

This gets the values that exist in the text20 field and puts them into an
array.
I'm cutting and pasting from an old file, so I'm not 100% sure this is the
best version. I think it may end up with an extra value in the array, but
you can figure that out.
I usually call it from another subprocedure and then traverse the resulting
array.

------snip-----------


Private Sub MyArray()
Dim myTask As Task
Dim myTasks As Tasks
Dim Addme As Boolean
Dim myList As String

Set myTasks = ActiveProject.Tasks
ArrayIndex = 0
ReDim Preserve WorkType(ArrayIndex)
For Each myTask In myTasks
Addme = False
If Not myTask Is Nothing Then
If Not myTask.summary Then
If myTask.Text20 <> "" Then
Addme = True
'check if it is already in the array
For ArrayIndex = 0 To UBound(WorkType)
If myTask.Text20 = WorkType(ArrayIndex) Then
Addme = False
End If
Next ArrayIndex
End If
'if it is not in the array then expand the array and add the new value
If Addme = True And myTask.Text20 <> "" Then
WorkType(ArrayIndex - 1) = myTask.Text20
ReDim Preserve WorkType(ArrayIndex)
End If
End If
End If
Next myTask
End Sub
 

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