Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Range, select, and printing arrays

Hi Jeff

Thanks for your reply.


ReDim p(1)

Why do you only ReDim the array if the user wants to see the primes? Does
the (1) just tell the compiler that it's 1 dimensional?


The ReDim statement is needed to declare the size of the array before you
can assign any value to it, ie not needed if the user don't want to see the
primes. See the array as a worksheet with 1 row and one column. As the code
ReDim later on the array will have 2 rows and 1 column and so on..


If Cell.Value = "Prime" Then

How do you tell VBA not to be case specific?


If LCase(Cell.Value) = "prime" Then



ReDim Preserve p(UBound(p) + 1)

I'm still not too sure on this. It looks like you are dimensioning the
array and keeping the values currently in the array. Why do you need the
+1? If the index goes from 1 to UBound (since we set this option), wont
UBound(p) do the trick?


UBound(p) is the current size of the last dimension in the array, so +1 is
needed to expand the array.

Preserve is as you think used to keep the values currently in the array.


For c = 1 To UBound(p) - 1

Don't we lose the last value in the array with the - 1 ?


No because the array is expaded after the last number is assigned to the
array. If you remove the -1 you will have a zero value as last item.

Hopes this was explaination enough.

Best regards,
Per

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
Concatenate / Select Subset of Arrays Andrew Hall NZ Excel Programming 2 March 17th 07 01:51 PM
Using Arrays to Fill a Range nenad Excel Programming 6 February 24th 07 07:24 PM
Using arrays or range in IF function - HELP PLS MickJJ Excel Worksheet Functions 1 February 10th 06 05:43 PM
Using arrays to select a series of cells [email protected] Excel Discussion (Misc queries) 1 December 27th 05 10:47 PM
Using Arrays to select Shapes Don Rouse Excel Programming 1 July 18th 04 07:27 AM


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