Read through Range and copy Cell data to Array

M

missleigh

I am trying to calculate status of a range based on:
When Data is present in Col1, Select Cell data for Col1 & Col 3 of same
row and write it to an arrary. I'd appreciate any help or direction
with this.

I've tried to set it up to: Read through a range of cells (currently
A2:J13), and where A1 is not empty, select the contents of A2 and E2
and write them to an array.

So far I have:

Sub TestStatusArray()
Dim TestCaseID As String
Dim Status As Boolean
Dim R As Integer
R = 2

Do While Not (IsEmpty(Cells(R, 1)))
Cells(R, 1).Copy << getting lost here


Loop
End Sub

I can't seem to figure out how to extract the contents of the cells and
and write
A2 to TestCaseID and E2 to Status.

Ideally, this data will then later be populated on a separate
worksheet.

I welcome any suggestions/recommendations/reading links.

Thanks,
Leigh
 
M

mudraker

leigh


try

Sub TestStatusArray()
Dim Col1() As String ' create a resizable array
Dim Col3() As String ' create a resizable array
Dim Rng As Range
Dim iCnt As Integer

iCnt = -1
'loop through column A range
For Each Rng In Range("a1:a13")
If Not IsEmpty(Rng) Then
iCnt = iCnt + 1
'resize arrays
ReDim Preserve Col1(iCnt)
ReDim Preserve Col3(iCnt)
'populate arrays
Col1(iCnt) = Rng.Value
Col3(iCnt) = Rng.Offset(0, 2).Value
End If
Next Rng
End Sub


Please note you can also create a fixed size array by using
Dim Col1(13) As String
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top