ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet arrays in VBA (https://www.excelbanter.com/excel-programming/431695-worksheet-arrays-vba.html)

Eero

Worksheet arrays in VBA
 
Hi,

I have created an array named by A in a workbook, say:

A={4;3;5;4;8;8;6}.

Now, how i can manipulate with this array in VBA environment? For
example to grab a value from A within a macro

Lars-Åke Aspelin[_2_]

Worksheet arrays in VBA
 
On Tue, 28 Jul 2009 13:12:31 -0700 (PDT), Eero
wrote:

Hi,

I have created an array named by A in a workbook, say:

A={4;3;5;4;8;8;6}.

Now, how i can manipulate with this array in VBA environment? For
example to grab a value from A within a macro



Try this:

Sub Eero()
third_element_of_A = Range("A")(3)
MsgBox third_element_of_A
End Sub

With your example data you should get a message box with 5 when you
run this macro.

Howeve, I would choose another name of the named range than "A" as
that can easily be confused with column A.

Hope this helps / Lars-Åke

Eero

Worksheet arrays in VBA
 
On 28 juuli, 23:36, Lars-Åke Aspelin
wrote:

Hi, Lars!

Thanks for responding. Actually the name A refers to no range but this
is a constant array.

On Tue, 28 Jul 2009 13:12:31 -0700 (PDT), Eero
wrote:

Hi,


I have created an array named by A in a workbook, say:


A={4;3;5;4;8;8;6}.


Now, how i can manipulate with this array in VBA environment? For
example to grab a value from A within a macro


Try this:

Sub Eero()
* third_element_of_A = Range("A")(3)
* MsgBox third_element_of_A
End Sub

With your example data you should get a message box with 5 when you
run this macro.

Howeve, I would choose another name of the named range than "A" as
that can easily be confused with column A.

Hope this helps / Lars-Åke




All times are GMT +1. The time now is 02:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com