#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Const Array

Hi,

I want to declare some arrays of constants.
One array has 5 elements as String, and some other arrays can have up to 100
elements as Single.
Can I do it in a single statement like: "Const InterestRate as Single =
0.07" but with allot more data?
Or do I have to first define a variable "Dim InterestRate (1 To 100) as
Single" and then assigning it by "InterestRate =
Evaluate("{0.07,0.071,0.06,0.063}") " (I'm not sure if this works...)


Best regards,
/Sören
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Const Array

I don't think that you can do it in the declaration, you need to dim it and
then assign it.

But just dim it as a variant variable, don't bound it.

Dim InterestRate

InterestRate = Activesheet.Evaluate("{0.07,0.071,0.06,0.063}")

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Sören_Marodören" wrote in message
...
Hi,

I want to declare some arrays of constants.
One array has 5 elements as String, and some other arrays can have up to
100
elements as Single.
Can I do it in a single statement like: "Const InterestRate as Single =
0.07" but with allot more data?
Or do I have to first define a variable "Dim InterestRate (1 To 100) as
Single" and then assigning it by "InterestRate =
Evaluate("{0.07,0.071,0.06,0.063}") " (I'm not sure if this works...)


Best regards,
/Sören



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Const Array

I have found a better soulution:

Dim InterestRate As Variant 'Not needed to do
InterestRate = Array(0.07, 0.071, 0.06, 0.063, 0.055, 0.059)

The Array function is new for me, but I found it in the book 'Excel 2003
Power Programming with VBA', by John Walkenbach, page 295.

BR,
/Sören

"Bob Phillips" wrote:

I don't think that you can do it in the declaration, you need to dim it and
then assign it.

But just dim it as a variant variable, don't bound it.

Dim InterestRate

InterestRate = Activesheet.Evaluate("{0.07,0.071,0.06,0.063}")

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Sören_Marodören" wrote in message
...
Hi,

I want to declare some arrays of constants.
One array has 5 elements as String, and some other arrays can have up to
100
elements as Single.
Can I do it in a single statement like: "Const InterestRate as Single =
0.07" but with allot more data?
Or do I have to first define a variable "Dim InterestRate (1 To 100) as
Single" and then assigning it by "InterestRate =
Evaluate("{0.07,0.071,0.06,0.063}") " (I'm not sure if this works...)


Best regards,
/Sören




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Const Array

Better? Different yes, but not necessarily better.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Sören_Marodören" wrote in message
...
I have found a better soulution:

Dim InterestRate As Variant 'Not needed to do
InterestRate = Array(0.07, 0.071, 0.06, 0.063, 0.055, 0.059)

The Array function is new for me, but I found it in the book 'Excel 2003
Power Programming with VBA', by John Walkenbach, page 295.

BR,
/Sören

"Bob Phillips" wrote:

I don't think that you can do it in the declaration, you need to dim it
and
then assign it.

But just dim it as a variant variable, don't bound it.

Dim InterestRate

InterestRate = Activesheet.Evaluate("{0.07,0.071,0.06,0.063}")

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Sören_Marodören" wrote in
message
...
Hi,

I want to declare some arrays of constants.
One array has 5 elements as String, and some other arrays can have up
to
100
elements as Single.
Can I do it in a single statement like: "Const InterestRate as Single =
0.07" but with allot more data?
Or do I have to first define a variable "Dim InterestRate (1 To 100) as
Single" and then assigning it by "InterestRate =
Evaluate("{0.07,0.071,0.06,0.063}") " (I'm not sure if this works...)


Best regards,
/Sören






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting CONST referencing a cell Value JMay Excel Programming 2 January 4th 07 03:02 AM
public const availability? lcoreyl[_22_] Excel Programming 5 July 1st 06 04:22 PM
Not recognizing a Const Dan T[_3_] Excel Programming 7 July 18th 04 12:45 AM
Public Const on a Drive MD Excel Programming 1 July 15th 04 03:53 PM
crash changing const to public const BrianB Excel Programming 0 August 4th 03 10:13 AM


All times are GMT +1. The time now is 07:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"