Filling an array with ranges

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I’m trying to write the first two rows and the last row of a range to a
two-dimensional array… Can this be done w/o looping?

Thanks!

Dim FlashArr()
Set wkb = ActiveWorkbook

Set rng = Range(“D4â€)
CellsAcross = Range(rng, rng.End(xlToRight)).Columns.Count

ReDim FlashArr(1 To 3, 1 To CellsAcross)
FlashArr = rng.Resize(2, CellsAcross)
FlashArr = Range(rng.End(xlDown), rng.End(xlDown).End(xlToRight))
 
Greg said:
Hi,

I’m trying to write the first two rows and the last row of a range to a
two-dimensional array… Can this be done w/o looping?

Thanks!

Dim FlashArr()
Set wkb = ActiveWorkbook

Set rng = Range(“D4â€)
CellsAcross = Range(rng, rng.End(xlToRight)).Columns.Count

ReDim FlashArr(1 To 3, 1 To CellsAcross)
FlashArr = rng.Resize(2, CellsAcross)
FlashArr = Range(rng.End(xlDown), rng.End(xlDown).End(xlToRight))

Sub abtest3()
Dim FlashArr

Set rng = range("D6")
CellsAcross = range(rng, rng.End(xlToRight)).Columns.Count
CellsDown = range(rng, rng.End(xlDown)).Rows.Count
Set rng1 = rng.Resize(2, CellsAcross)
Set rng2 = range(rng(CellsDown, 1), rng(CellsDown, CellsAcross))
rng1.Copy range("J1")
rng2.Copy range("J1").Offset(2)
Set rng3 = range("J1").Resize(3, CellsAcross)
ReDim FlashArr(1 To 3, 1 To CellsAcross)
FlashArr = rng3
End Sub

Alan Beban
 

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

Back
Top