Array or Dictionaries?

ClimoC

Well-known Member
Joined
Aug 21, 2009
Messages
584
Hello

I'm quite comfortable with building an array from a Project file, 25 columns wide and 10000 rows long, then dumping it into an Excel Spreadsheet.

I'm now essentially doing something similar in reverse though. I have a uniqueID-type column as column1 in the excel spreadsheet, and need to match this to a field in Project, then overwrite all the other fields based on what is in the array row.

My question is whether it would be (noticably) quicker to try and do this as an array, rather than with 20 scripting dictionaries? I know that seems like a rhetorical question on the face of it, but dictionaries are much easier to use, and I have access to the '.exists' functions, simple and quick adding etc.

And I suppose, how easy is it to 'loop' through my array and test conditions on it? I'd build a dictionary containing the task IDs and UniqueIDs : Would it be as simple as (quick example:)
Code:
For ArrR = 0 to UBound(MyArray,1)
If Dict.exists(MyArray(ArrR,1)) then
With Activeproject.tasks(MyArray(ArrR,1))
.Name = MyArray(ArrR,2)
.ResourceName = MyArray(ArrR,3)
.Duration = MyArray(ArrR,4) /480
.Text1 = MyArray(ArrR,5)
'etc
'etc
'etc
End With
Else
With Activeproject.tasks.add(MyArray(ArrR,1))
Dict.Add(MyArray(ArrR,1), .ID)
.Name = MyArray(ArrR,2)
'etc
'etc
End With
End If

ArrR = ArrR + 1
Loop

...Or is there something I'm fundamentally missing here?

Thanks
C
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,216,096
Messages
6,128,809
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top