Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to optimize my code 2

Status
Not open for further replies.

JensKKK

Technical User
May 8, 2007
119
GB
Is there a more elegant way to assign data to an array?

Thanks for your help.

source(1) = 5000
source(2) = 6000
source(3) = 7000
source(4) = 8000
source(5) = 12000
source(6) = 13000

Page_Name(1) = "Average"
Page_Name(2) = "T-Test"
Page_Name(3) = "% Inhibition"
Page_Name(4) = "dRFU"
Page_Name(5) = "Standard Deviation"
Page_Name(6) = "Coefficient of Variation"
 
same thing as from your earlier thread, you can assign to an array using hte same method

thread707-1387719

Code:
Dim Page_name()

Page_name = array("average",T-test",drFU)




Chance,

F, G + B
 
Ii's not more elegant and applies only to variant variable, but could be shorter:
Code:
Option Base 1

Sub UseArray()
Dim Source, Page_Name
Source = Array(5000, 6000, 7000, 8000, 12000, 13000)
Page_Name = Array("Average", "T-Test", "% Inhibition", "dRFU", "Standard Deviation", "Coefficient of Variation")
For i = 1 To 6
    MsgBox Source(i), vbOKOnly, Page_Name(i)
Next i
End Sub

combo
 
Thanks Chance & Combo.

I should have remembered my own thread.

 




You might also consider storing the array elements in a table on a hidden sheet. Then load the array from the table. Much easier to maintain than data in code.

Skip,

[glasses] When a wee mystic is on the loose..
It's a Small Medium at Large! [tongue]
 
happens to the best of us , especially on friday afternoons

Chance,

F, G + B
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top