View Single Post
  #17   Report Post  
Posted to microsoft.public.excel.programming
Jimmy Jimmy is offline
external usenet poster
 
Posts: 22
Default Variables in Declaring an Array

You're right, Alan.
Though, the other half of the time I am directed to make my sample
codes longer and more
detailed. Go Figure.

I think that I figured out a way to do it without trying to use a 2dim
array that must refresh itself. Let's keep our fingers crossed that
this will be the magic bullet that I am looking for.


I apprciate all you help.
Thanks,
Jimmy




Alan Beban wrote:
It would be easier on responders if you were to use a simpler example to
focus on the problem you're trying to solve, a la

Dim arr()
ReDim arr(2,3) 'or whatever
'...whatever
ReDim arr(?,?) 'or whatever

Alan Beban

Jimmy wrote:
First of all, thanks to all who endeavor to help me with this project:
Here it is:



I want to make a 2dim array.
The current code populates that array at Row15 (see below).
I would like to change this 1dim to a 2dim

The main problem is that I am constantly refrishing the array at either
row33 or row35.

Thank you in advance,
Jimmy


1 ent_ku = Range("B2").Value
2 ent_or= Range("F2").Value
3 currentlastrow = Range("B65536").End(xlUp).Row
4 j = 2
5 pvFlag = False
6 ifMatch = False
7 Range("A1").Select
8
9 For i = Range("B2").Row To currentlastrow Step 1
10 h = i
11 current_Desc = Range("D" & i).Value
12 If Range("B" & i).Value = ent_ku Then
13 ifMatch = True
14 ReDim Preserve myArray(q)
15 myArray(q) = Range("F" & i).Value
16 If Range("F" & i).Value = "PVJco" Then
17 pvFlag = True
18 pvPrice = Range("I" & i).Value
19 pvChgDate = Range("J" & i).Value
20 End If
21
22 q = q + 1
23
24 ElseIf pvFlag = True Then
25 q = 0
26 locust = Application.Min(Range("I" & j, "I" &
(i - 1)))
27 percentAbv = (pvPrice - locust) / locust
28 lowCompet = Application.Min(Range("I" & j, "I" & (i -
1))).Row
29 i = i - 1
30
31 j = i
32 pvFlag = False
33 ReDim myArray(q)

ElseIf pvFlag = False Then
34 q = 0
35 ReDim myArray(q)
36 i = i - 1
37 End If
38
39 ActiveCell.Offset(1, 0).Select
40 ent_ku = Range("B" & h).Value
41
42 Next

Jimmy wrote:
Thanks, Alan.
I got a little side tracked on another "%^#@(*&^*($" today.
But when I get back to this one, I'll post more here.

In the mean time, I have another question that I'm about to ask on a
separate posting.

Thanks again,
Jimmy




Alan Beban wrote:
Jimmy wrote:
Jim,
I'm still on the same project, but our team has decided to use a
two-dim array.
How can I get "redim preserve myarray(n,o)" to work?
I'm having the worst time with this.
Thanks so much,
Jimmy
A little more info would be helpful. I suspect your difficulty arises
from the fact that the ReDim Preserve structure will allow you to change
only the last dimension of the array. E.g., if the array has been
dimensioned with 2 "rows" and 3 "columns", you can use ReDim Preserve to
change the number of "columns" but not the number of "rows". You might
want to post back with a sample code snippet if that's your difficulty.

Alan Beban