#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default variable

Hi, Ive got 20 variables named xmean1, xmean2,
xmean3............xmean20. I want to refer to these with, For I = 1 TO
20. Ive tried, xmean(i), xmean & i and (xmean(i)). Any idea on how to
do this, or is this not possible.
Regards Robert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default variable

Hi,
I would think you need to place the xmean variables in an array i.e dim
xmean(1 to 20)

They can then be referenced in a loop with xmean(i), i being the loop
variable.

Don

wrote in message
ups.com...
Hi, Ive got 20 variables named xmean1, xmean2,
xmean3............xmean20. I want to refer to these with, For I = 1 TO
20. Ive tried, xmean(i), xmean & i and (xmean(i)). Any idea on how to
do this, or is this not possible.
Regards Robert



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default variable

Create an array of variables

Dim xmean(1 to 20)

... load the array

For i = 1 To 20
Debug.Pring xmean(i)
Next i

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

wrote in message
ups.com...
Hi, Ive got 20 variables named xmean1, xmean2,
xmean3............xmean20. I want to refer to these with, For I = 1 TO
20. Ive tried, xmean(i), xmean & i and (xmean(i)). Any idea on how to
do this, or is this not possible.
Regards Robert



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default variable

Thankyou for your replys, this is perfect. Can I use the same for a
static variable. ie
Static xmean as integer. Thanks Again
Regards Robert

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

Yes you can but you need to size it in the declaration, and also Integer is
really redundant in 32 bit systems

Static xmean(1 To 20) As long

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

wrote in message
ups.com...
Thankyou for your replys, this is perfect. Can I use the same for a
static variable. ie
Static xmean as integer. Thanks Again
Regards Robert





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default variable

Thanks for your advice, much appreciated.
Regards Robert

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default variable

Sorry, just realised another part to this. Ive been using Erase xmean1,
how do I use this with a loop, eg for i = 1 to 20 Erase(i) next i.
Triead this but didnt work
Regards Robert

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
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM
Pivot Table - Object variable or with block variable not set? George Nicholson[_2_] Excel Programming 1 April 16th 04 09:12 PM


All times are GMT +1. The time now is 05:24 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"