Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default assigning values to array

Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default assigning values to array

Hi Juggernath,

One possibility:

Dim arr As Variant

arr = Array(1, 2, 4)

---
Regards,
Norman



"Juggernath" wrote in message
...
Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default assigning values to array

Unfortunately not.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Juggernath" wrote in message
...
Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default assigning values to array


"Norman Jones" wrote in message
...
Hi Juggernath,

One possibility:

Dim arr As Variant

arr = Array(1, 2, 4)

---
Regards,
Norman



"Juggernath" wrote in message
...
Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4



I tried it already... it says "cannot assign to array" when it comes to 2nd
line.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default assigning values to array

Well it worked fine for me, as I am sure it did for Norman.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Juggernath" wrote in message
...

"Norman Jones" wrote in message
...
Hi Juggernath,

One possibility:

Dim arr As Variant

arr = Array(1, 2, 4)

---
Regards,
Norman



"Juggernath" wrote in message
...
Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4



I tried it already... it says "cannot assign to array" when it comes to

2nd
line.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default assigning values to array

Hi Juggernath,

As Bob suggests, the code worked in my test.

How did you dim your array?

---
Regards,
Norman



"Juggernath" wrote in message
...

"Norman Jones" wrote in message
...
Hi Juggernath,

One possibility:

Dim arr As Variant

arr = Array(1, 2, 4)

---
Regards,
Norman



"Juggernath" wrote in message
...
Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4



I tried it already... it says "cannot assign to array" when it comes to
2nd line.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default assigning values to array

Juggernath wrote:
Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4



If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook

Dim A() As Integer
Assign Array(1, 2, 4), A

Alan Beban
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default assigning values to array


"Norman Jones" wrote in message
...
Hi Juggernath,

As Bob suggests, the code worked in my test.

How did you dim your array?

"Norman Jones" wrote in message
...
Hi Juggernath,

One possibility:

Dim arr As Variant

arr = Array(1, 2, 4)

---
Regards,
Norman


Thanks for trying to help so far...

Here is my code (Custom function in VBA - excel - OfficeXP)

Dim A(11) As Double
A = Array(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475, -0.7361,
0.1844, 0.1056, 0.6134, 0.721)

and here is my error when i run a function using subroutine on a given
picture
http://www.rgn.hr/~dvulin/myerror.gif

(i tried dim A(10) as double, and (1 to 11)...etc.)


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default assigning values to array

Hi Juggernath,

Try changing:

Dim A(11) As Double


to:

Dim A As Variant

---
Regards,
Norman


"Juggernath" wrote in message
...

"Norman Jones" wrote in message
...
Hi Juggernath,

As Bob suggests, the code worked in my test.

How did you dim your array?

"Norman Jones" wrote in message
...
Hi Juggernath,

One possibility:

Dim arr As Variant

arr = Array(1, 2, 4)

---
Regards,
Norman


Thanks for trying to help so far...

Here is my code (Custom function in VBA - excel - OfficeXP)

Dim A(11) As Double
A = Array(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475, -0.7361,
0.1844, 0.1056, 0.6134, 0.721)

and here is my error when i run a function using subroutine on a given
picture
http://www.rgn.hr/~dvulin/myerror.gif

(i tried dim A(10) as double, and (1 to 11)...etc.)




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default assigning values to array

Look again

http://www.rgn.hr/~dvulin/myerror.gif

P.S.

see the part bellow ;)



"Norman Jones" wrote in message
...

Hi Juggernath,




Try changing:




Dim A(11) As Double




to:




Dim A As Variant




---


Regards,


Norman






"Juggernath" wrote in message


...




"Norman Jones" wrote in message


...


Hi Juggernath,




As Bob suggests, the code worked in my test.




How did you dim your array?




"Norman Jones" wrote in message


...


Hi Juggernath,




One possibility:




Dim arr As Variant




arr = Array(1, 2, 4)




---


Regards,


Norman






Thanks for trying to help so far...




Here is my code (Custom function in VBA - excel - OfficeXP)




Dim A(11) As Double


A = Array(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475,


-0.7361,


0.1844, 0.1056, 0.6134, 0.721)




and here is my error when i run a function using subroutine on a


given


picture


http://www.rgn.hr/~dvulin/myerror.gif




(i tried dim A(10) as double, and (1 to 11)...etc.)













  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default assigning values to array

Read Norman's response again.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Juggernath" wrote in message
...
Look again

http://www.rgn.hr/~dvulin/myerror.gif

P.S.

see the part bellow ;)



"Norman Jones" wrote in message
...

Hi Juggernath,




Try changing:




Dim A(11) As Double




to:




Dim A As Variant




---


Regards,


Norman






"Juggernath" wrote in message


...




"Norman Jones" wrote in message


...


Hi Juggernath,




As Bob suggests, the code worked in my test.




How did you dim your array?




"Norman Jones" wrote in message


...


Hi Juggernath,




One possibility:




Dim arr As Variant




arr = Array(1, 2, 4)




---


Regards,


Norman






Thanks for trying to help so far...




Here is my code (Custom function in VBA - excel - OfficeXP)




Dim A(11) As Double


A = Array(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475,


-0.7361,


0.1844, 0.1056, 0.6134, 0.721)




and here is my error when i run a function using subroutine on a


given


picture


http://www.rgn.hr/~dvulin/myerror.gif




(i tried dim A(10) as double, and (1 to 11)...etc.)













  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default assigning values to array

Hi Juggernath,

Look again

http://www.rgn.hr/~dvulin/myerror.gif

P.S.

see the part bellow ;)


In common with many in this NG, I never open unknown attachments.

Perhaps you could articulate the gif message?

In the meanwhile try the following:

'==============
Sub Tester()
Dim arr As Variant
Dim i As Long


arr = Array(0.3265, -1.07, -0.5339, 0.01569, -0.05165, 0.5475, _
-0.7361, 0.1844, 0.1056, 0.6134, 0.721)
For i = LBound(arr) To UBound(arr)
Debug.Print arr(i)
Next i

End Sub
'<<==============

Now check the contents of your immediate window.

---
Regards,
Norman



"Juggernath" wrote in message
...
Look again

http://www.rgn.hr/~dvulin/myerror.gif

P.S.

see the part bellow ;)



"Norman Jones" wrote in message
...

Hi Juggernath,




Try changing:




Dim A(11) As Double




to:




Dim A As Variant




---


Regards,


Norman



  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default assigning values to array

Hi Bob,

You used a mere four words to convey what took me an entire post!

Unfortunately, when I responded your post was not visible - to me!

---
Regards,
Norman



"Bob Phillips" wrote in message
...
Read Norman's response again.

--

HTH

RP
(remove nothere from the email address if mailing direct)



  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default assigning values to array

Hi Norman,

I try to be to the point :-))

Bob


"Norman Jones" wrote in message
...
Hi Bob,

You used a mere four words to convey what took me an entire post!

Unfortunately, when I responded your post was not visible - to me!

---
Regards,
Norman



"Bob Phillips" wrote in message
...
Read Norman's response again.

--

HTH

RP
(remove nothere from the email address if mailing direct)





  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default assigning values to array

Well, with respect to being to the point, the responders are suggesting
code to load a Variant() type array, while the OP is looking to load a
Double() type array, and never the twain shall meet.

As I suggested in my earlier post, if the functions in the freely
downloadable file at http://home.pacbell.net/beban are available to
one's workbook, one might use

Dim A() As Double
Assign Array(1,2,4),A

Alan Beban

Bob Phillips wrote:
Hi Norman,

I try to be to the point :-))

Bob


"Norman Jones" wrote in message
...

Hi Bob,

You used a mere four words to convey what took me an entire post!

Unfortunately, when I responded your post was not visible - to me!

---
Regards,
Norman



"Bob Phillips" wrote in message
...

Read Norman's response again.

--

HTH

RP
(remove nothere from the email address if mailing direct)







  #16   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default assigning values to array

Hi Alan,

Well, with respect to being to the point, the responders are suggesting
code to load a Variant() type array, while the OP is looking to load a
Double() type array, and never the twain shall meet.


The OP's initial post said:

'========================
Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4

'========================

My response was directed to that question.

the responders are suggesting code to load a Variant() type array


Also, if:

the OP is looking to load a Double() type array, and never the twain shall
meet.


why did you suggest a Single() type array in your response?


Regards,
Norman


"Alan Beban" wrote in message
...
Well, with respect to being to the point, the responders are suggesting
code to load a Variant() type array, while the OP is looking to load a
Double() type array, and never the twain shall meet.

As I suggested in my earlier post, if the functions in the freely
downloadable file at http://home.pacbell.net/beban are available to one's
workbook, one might use

Dim A() As Double
Assign Array(1,2,4),A

Alan Beban

Bob Phillips wrote:
Hi Norman,

I try to be to the point :-))

Bob


"Norman Jones" wrote in message
...

Hi Bob,

You used a mere four words to convey what took me an entire post!

Unfortunately, when I responded your post was not visible - to me!

---
Regards,
Norman



"Bob Phillips" wrote in message
...

Read Norman's response again.

--

HTH

RP
(remove nothere from the email address if mailing direct)




  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default assigning values to array

Norman Jones wrote:
Hi Alan,


Well, with respect to being to the point, the responders are suggesting
code to load a Variant() type array, while the OP is looking to load a
Double() type array, and never the twain shall meet.



The OP's initial post said:

'========================
Is there some elegant way to assign values to array, for ex:
dim A(3) as integer {1,2,4}

instead of
dim A(3) as integer

A(1)=1
A(2)=2
A(3)=4

'========================

My response was directed to that question.


Understood. But the OP's post at 9:28am on 11/24 stated

"I tried it already... it says "cannot assign to array" when it comes to
2nd line."

made it clear (at least to me), when coupled with his original posting
including

Dim A(3) as integer

that the problem was he was continuing to try to load a non-Variant()
type array.

Cheers,
Alan Beban
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
assigning values to an array Juggernath[_4_] Excel Programming 2 November 25th 05 03:38 AM
Assigning a value to an array cell Srikanth Ganesan[_2_] Excel Programming 1 September 17th 04 03:09 AM
Assigning 10x1 array to 2nd collumn of 10x3 array Alan Beban[_2_] Excel Programming 0 July 30th 04 01:38 AM
Assigning 10x1 array to 2nd collumn of 10x3 array Myrna Larson Excel Programming 0 July 29th 04 11:57 PM
Assigning Array Values MWE[_16_] Excel Programming 6 January 26th 04 04:35 AM


All times are GMT +1. The time now is 10:08 AM.

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

About Us

"It's about Microsoft Excel"