Replace "A2" with Active cell

D

Denys

Good day everyone,

Would someone be kind enough to let me know how I could replace "A2"
by the active cell in the following formula:


With ActiveSheet
.Cells(1, 1).End(xlDown).Offset(1).Select
.Range("A2", .Cells(UBound(Arr, 1), UBound(Arr,
2))).Value = Arr
End With

Thank you for your time

Denys
 
G

GS

Denys submitted this idea :
Good day everyone,

Would someone be kind enough to let me know how I could replace "A2"
by the active cell in the following formula:


With ActiveSheet
.Cells(1, 1).End(xlDown).Offset(1).Select
.Range("A2", .Cells(UBound(Arr, 1), UBound(Arr,
2))).Value = Arr
End With

Thank you for your time

Denys

To 'dump' an array into a range you need to pick the top left cell and
resize that to the rows/cols of the array. So...

ActiveCell.Resize(Ubound(Arr, 1), UBound(Arr, 2) = Arr

Also, it's not necessary to select anything and so...

Sub DoStuff()
' Reads a 5Row x 5Col range into an array,
' then dumps the data back into the sheet
' at the 1st empty row below existing data.
Dim Arr
Arr = Range("A1:E5")
Cells(1, 1).End(xlDown).Offset(1).Resize(UBound(Arr, 1), UBound(Arr,
2)) = Arr
End Sub
 
G

GS

If you want the very last row in column "A" in cases where there might
be blank cells...

Sub DoStuff()
' Reads a 5Row x 5Col range into an array,
' then dumps the data back into the sheet
' at the 1st empty row below existing data.
Dim Arr, v
Arr = Range("A1:E5")
Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(Arr, 1),
UBound(Arr, 2)) = Arr
End Sub

Watch for line wrap...
 

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