Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Define an array with variable size

Hi all,

In my Excel VBA program, I have to define an array, but the dimension of
this array is a variable, which dependents on the value in cell B1. I think
this is an easy problem but I don't know how to solve it _<

Thanks very much for your help!!

Best wishes
C.F. Yiu


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Define an array with variable size

Hi
have a look at 'ReDim' in the Exel VBA help for this

-----Original Message-----
Hi all,

In my Excel VBA program, I have to define an array,

but the dimension of
this array is a variable, which dependents on the value

in cell B1. I think
this is an easy problem but I don't know how to solve it
_<

Thanks very much for your help!!

Best wishes
C.F. Yiu


.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Define an array with variable size

Hi Choi Fan,

Sub Test()
Dim Arr() As Variant
Dim i As Long

i = Range("A1").Value
ReDim Arr(1 To i)

End Sub


---
Regards,
Norman



"Yiu Choi Fan" wrote in message
...
Hi all,

In my Excel VBA program, I have to define an array, but the dimension

of
this array is a variable, which dependents on the value in cell B1. I

think
this is an easy problem but I don't know how to solve it _<

Thanks very much for your help!!

Best wishes
C.F. Yiu




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default Define an array with variable size

Choi Fan,

Option Explicit
Sub ArrayDimension()
Dim vArray As Variant
ReDim vArray(0 To Sheets(1).Range("A1").Value)
MsgBox UBound(vArray, 1)
End Sub

The traffic is hell in Central if you are trying to get home that way. Just
took me 25 minutes to get past the Convention Centre from the Star Ferry.

Robin Hammond
www.enhanceddatasystems.com

"Yiu Choi Fan" wrote in message
...
Hi all,

In my Excel VBA program, I have to define an array, but the dimension

of
this array is a variable, which dependents on the value in cell B1. I

think
this is an easy problem but I don't know how to solve it _<

Thanks very much for your help!!

Best wishes
C.F. Yiu




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
Define Variable Name using VBA GTReferee Excel Discussion (Misc queries) 2 January 21st 09 06:37 PM
Using a Variable to Define Series Posse John Charts and Charting in Excel 2 August 30th 06 01:18 PM
How to find out the size of a variable-size array ? Adrian[_7_] Excel Programming 1 July 6th 04 09:12 AM
Define variable range acberry Excel Programming 2 May 12th 04 02:44 PM


All times are GMT +1. The time now is 03:27 PM.

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"