PC Review


Reply
Thread Tools Rate Thread

array help needed

 
 
Rivers
Guest
Posts: n/a
 
      2nd Nov 2008
hi guys i need what seems so simple but i cant figure it out.

i need an array to hold all the values it finds in column be starting from
range be6 and continuing down wards untill an empty cell is found and then
end the array

can anyone help

rivers
 
Reply With Quote
 
 
 
 
Rivers
Guest
Posts: n/a
 
      2nd Nov 2008
sorry but i donot understand how to use this array.

my cell values store spreadsheet names and i wish to store them all in the
variable and then call them into a

add.item loop

can you please explain how i can do this a seriously stuck with your answer

"shg" wrote:

>
> Code:
> --------------------
> Dim vArr As Variant
> vArr = Range("BE6", Range("BE6").End(xlDown)).Value
>
> --------------------
>
>
> --
> shg
> ------------------------------------------------------------------------
> shg's Profile: http://www.thecodecage.com/forumz/member.php?userid=13
> View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=24240
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      2nd Nov 2008
You can pick up the values in a range this way and build a two dimensional array
(# rows by # columns). In this case, it's # rows by 1 column.

You can use this to loop through the values in the array:

Dim vArr As Variant
Dim iCtr As Long

With ActiveSheet
vArr = .Range("BE6", .Range("BE6").End(xlDown)).Value
End With

For iCtr = LBound(vArr, 1) To UBound(vArr, 1)
MsgBox vArr(iCtr, 1)
Next iCtr



Rivers wrote:
>
> sorry but i donot understand how to use this array.
>
> my cell values store spreadsheet names and i wish to store them all in the
> variable and then call them into a
>
> add.item loop
>
> can you please explain how i can do this a seriously stuck with your answer
>
> "shg" wrote:
>
> >
> > Code:
> > --------------------
> > Dim vArr As Variant
> > vArr = Range("BE6", Range("BE6").End(xlDown)).Value
> >
> > --------------------
> >
> >
> > --
> > shg
> > ------------------------------------------------------------------------
> > shg's Profile: http://www.thecodecage.com/forumz/member.php?userid=13
> > View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=24240
> >
> >


--

Dave Peterson
 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      2nd Nov 2008
You show 'add.item loop' in your latest post... exactly what are you
planning to add your array elements to? While the syntax you posted is
incorrect for my guess of a ListBox or ComboBox; however, if that is indeed
what you want to populate, you do not need to load up an array first in
order to do it. Consider this example for a ListBox on a UserForm (same code
for a ComboBox except for the control's name, of course)...

Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "BE").End(xlUp).Row
Me.ListBox1.RowSource = "BE6:BE" & LastRow
End With

If my guess was correct and if you have trouble adapting my code, tell us
what control you have, where it is located (UserForm or Worksheet) and, if
directly on a worksheet, which toolbar you got it from.

--
Rick (MVP - Excel)


"Rivers" <(E-Mail Removed)> wrote in message
news:6D53B28E-4D14-4DD4-9F30-(E-Mail Removed)...
> sorry but i donot understand how to use this array.
>
> my cell values store spreadsheet names and i wish to store them all in the
> variable and then call them into a
>
> add.item loop
>
> can you please explain how i can do this a seriously stuck with your
> answer
>
> "shg" wrote:
>
>>
>> Code:
>> --------------------
>> Dim vArr As Variant
>> vArr = Range("BE6", Range("BE6").End(xlDown)).Value
>>
>> --------------------
>>
>>
>> --
>> shg
>> ------------------------------------------------------------------------
>> shg's Profile: http://www.thecodecage.com/forumz/member.php?userid=13
>> View this thread:
>> http://www.thecodecage.com/forumz/sh...ad.php?t=24240
>>
>>


 
Reply With Quote
 
ShaneDevenshire
Guest
Posts: n/a
 
      3rd Nov 2008
Hi,

I think the OP doesn't realize that the one line
vArr = Range("BE6", Range("BE6").End(xlDown)).Value
loads the entire array in one step.

Here is some sample code for the op

Sub testArray()
Dim myArray As Variant
Dim element As Variant
myArray = [A1:A10]
For Each element In myArray
MsgBox element
Next element
End Sub

So you can use a for each loop to work with your array.
--
Thanks,
Shane Devenshire


"Rick Rothstein" wrote:

> You show 'add.item loop' in your latest post... exactly what are you
> planning to add your array elements to? While the syntax you posted is
> incorrect for my guess of a ListBox or ComboBox; however, if that is indeed
> what you want to populate, you do not need to load up an array first in
> order to do it. Consider this example for a ListBox on a UserForm (same code
> for a ComboBox except for the control's name, of course)...
>
> Dim LastRow As Long
> With Worksheets("Sheet1")
> LastRow = .Cells(.Rows.Count, "BE").End(xlUp).Row
> Me.ListBox1.RowSource = "BE6:BE" & LastRow
> End With
>
> If my guess was correct and if you have trouble adapting my code, tell us
> what control you have, where it is located (UserForm or Worksheet) and, if
> directly on a worksheet, which toolbar you got it from.
>
> --
> Rick (MVP - Excel)
>
>
> "Rivers" <(E-Mail Removed)> wrote in message
> news:6D53B28E-4D14-4DD4-9F30-(E-Mail Removed)...
> > sorry but i donot understand how to use this array.
> >
> > my cell values store spreadsheet names and i wish to store them all in the
> > variable and then call them into a
> >
> > add.item loop
> >
> > can you please explain how i can do this a seriously stuck with your
> > answer
> >
> > "shg" wrote:
> >
> >>
> >> Code:
> >> --------------------
> >> Dim vArr As Variant
> >> vArr = Range("BE6", Range("BE6").End(xlDown)).Value
> >>
> >> --------------------
> >>
> >>
> >> --
> >> shg
> >> ------------------------------------------------------------------------
> >> shg's Profile: http://www.thecodecage.com/forumz/member.php?userid=13
> >> View this thread:
> >> http://www.thecodecage.com/forumz/sh...ad.php?t=24240
> >>
> >>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
more array help needed needhelp Microsoft Excel Programming 5 10th Aug 2009 06:21 AM
Array Help needed Marc Microsoft Access 0 14th Dec 2006 04:18 PM
Help in array of array of classes needed =?Utf-8?B?RGVzcGVyYXRl?= Microsoft C# .NET 4 6th Jun 2004 08:00 AM
Help in array of array of classes needed razovy Microsoft C# .NET 1 6th Jun 2004 04:51 AM
Array Help Needed Gav !! Microsoft Excel Programming 2 26th Oct 2003 07:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:35 PM.