Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
 
Posts: n/a
Default using VB to read in a column of values of varying length into an array

Hi,

I am having trouble reading values from excel into an array. I have
data that begins in cell E4 and will have varying length based on how
much data the user lists. How can I read that data into an array.
This is what I have tried so far:

Dim k as integer

ActiveCell.Range("E4").Select
While activecell.value < ""
yArray(k) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
k=k+1
Wend

What am I doing wrong or what should I be doing? Any help is much
appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default using VB to read in a column of values of varying length into an array

yArray = Range(Range("E4"),Cells(Rows.Count,"E").End(xlUp))

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

wrote in message
oups.com...
Hi,

I am having trouble reading values from excel into an array. I have
data that begins in cell E4 and will have varying length based on how
much data the user lists. How can I read that data into an array.
This is what I have tried so far:

Dim k as integer

ActiveCell.Range("E4").Select
While activecell.value < ""
yArray(k) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
k=k+1
Wend

What am I doing wrong or what should I be doing? Any help is much
appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Trevor Shuttleworth
 
Posts: n/a
Default using VB to read in a column of values of varying length into an array

Dim aArray As Variant
aArray = Application.WorksheetFunction.Transpose _
(Range("E4:E" & Range("E65536").End(xlUp).Row))

To test:

Dim aArray As Variant
Dim i As Long
aArray = Application.WorksheetFunction.Transpose _
(Range("E4:E" & Range("E65536").End(xlUp).Row))
For i = LBound(aArray) To UBound(aArray)
MsgBox i & " " & aArray(i)
Next 'i


Regards

Trevor


wrote in message
oups.com...
Hi,

I am having trouble reading values from excel into an array. I have
data that begins in cell E4 and will have varying length based on how
much data the user lists. How can I read that data into an array.
This is what I have tried so far:

Dim k as integer

ActiveCell.Range("E4").Select
While activecell.value < ""
yArray(k) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
k=k+1
Wend

What am I doing wrong or what should I be doing? Any help is much
appreciated.



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
Column picked randomly with probability relative to number of entr Neil Goldwasser Excel Worksheet Functions 4 May 30th 06 08:55 AM
How do I compare string values in one column to another column? Nick N. Excel Worksheet Functions 1 April 29th 06 02:56 AM
Summing one column if two other columns' values appear in other sh JulieU Excel Worksheet Functions 3 April 18th 06 04:48 PM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM
How sum values in column B using values in column A as the conditi oldgrayelf Excel Worksheet Functions 5 February 4th 05 09:03 PM


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