Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Extracting values from cells (in one column) and putting in an arr

Hi All,

VBA newbie here. I haven't done my homework fully yet so I am not asking
for the complete answer, rather some help to jump start my thinking process.

What I need to do is come up with a code that will read the value (it's an
integer) from cells in one column i.e. column A.

The start value is in cell A14 and then it appears in every 2nd consecutive
cell down from A14. For example, A14 contains 1, then A16 contains 2, A18
contains 3 and so on...so I'd like to read all the values in an array, then
stop when the cells are empty.

How can I get around this? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Extracting values from cells (in one column) and putting in anarr

Hi

Try this:

Sub ValToArr()
Dim MyArray
Set StartCell = Range("A14")
Set EndCell = Range("A" & Rows.Count).End(xlUp)
rowCount = EndCell.Row - StartCell.Row
ReDim MyArray(rowCount / 2 + 1)
For r = StartCell.Row To EndCell.Row Step 2
i = i + 1
MyArray(i) = Cells(r, "A").Value
Next
End Sub

Regards,
Per


On 26 Jan., 22:55, Varun wrote:
Hi All,

VBA newbie here. *I haven't done my homework fully yet so I am not asking
for the complete answer, rather some help to jump start my thinking process.

What I need to do is come up with a code that will read the value (it's an
integer) from cells in one column i.e. column A.

The start value is in cell A14 and then it appears in every 2nd consecutive
cell down from A14. *For example, A14 contains 1, then A16 contains 2, A18
contains 3 and so on...so I'd like to read all the values in an array, then
stop when the cells are empty.

How can I get around this? *Thanks.


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
Putting column values in multiple rows ChBoodts Excel Programming 1 July 18th 05 08:50 PM
Populate a column by extracting unique values from another column? Mike Palmer Excel Worksheet Functions 2 June 10th 05 03:21 PM
putting values into cells is slow inquirer Excel Programming 5 May 13th 05 03:49 AM
Putting correct values in cells Nick Excel Programming 1 August 26th 04 04:01 PM
putting ' in a column of cells Peter McCaul Excel Programming 1 August 14th 04 06:11 PM


All times are GMT +1. The time now is 10:00 PM.

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"