How to copy Range Array to specific destination in VBA?

Son Gozita

Please help I've search everywhere but it seems all methods failed. This is my Code

Dim MyArray(1 To 20) As Range
Dim A0 As Integer
Cells(1, 1).Select

For A0 = 1 To 20
Set MyArray(A0) = Range(ActiveCell, ActiveCell.Offset(1, 0))
ActiveCell.Offset(0, 1).Select
Next



Range("A15:T15") = Application.Transpose(MyArray)
Range("A15:T16") = Application.Transpose(MyArray)
Range("A15:T15") = WorksheetFunction.Transpose(MyArray)
Range("A15:T16") = WorksheetFunction.Transpose(MyArray)

I've tried every last 4 procedure/s. But failed. This is just summary to make it east to read. Thanks

3-14159265358979323846264

Going a bit further than my comment ... try this as an example ...

Sub a()

Dim x(2) As Integer
x(0) = 1
x(1) = 2

Range("A10:B10").Value = x

End Sub

This correctly outputs the array into cells A10 and B10


In the case of a 2D array, you can use this example ...

Sub a()

Dim x(2,2) As Integer
x(0,0) = 1
x(0,1) = 2
x(1,0) = 3
x(1,1) = 4

Range("A10:B11").Value = x

End Sub

You still don't need transpose though!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

.copy _ Destination syntax, Range Error

Find a specific String in a range and copy it to another field in VBA

How do I copy some specific columns from a given range which is auto filtered in Excel VBA?

How to paste array into a range [VBA] - Error 1004

Copy range to destination and return destination range

vba: copy sheet with named destination

Copy specific range

VBA How to check if an Array contains a string in a Range

VBA Loop : Copy / Paste destination offsetting

VBA copy paste array/range onto another tab

VBA Copy Destination but as values

How to copy all files in all directories with specific filename to one destination?

Excel VBA - Error in code to copy to specific sheet, dependent on range

VBA copy range of rows

copy and paste specific cell(using .find) in worksheet array using vba

Copy Range with VBA to clipboard

VBA to copy values from specific range in many worksheets of source workbook to same range in many worksheets of destination workbook

How to copy and paste specific range n times?

VBA Copy Variable Range

How to Copy Filtered Range To Array?

How to copy the data to destination range when there is any update in google sheet?

Open FileDialog in VBA Microsoft access and select just specific file extensions and copy to specific dynamic destination

Copy range using array, insert in new sheet into specific columns

VBA How to copy range data without headers

VBA Find if an array (made up of range) contains a specific value

Copy- Paste above row's Range if a specific range is empty and another is not (VBA)

How to copy a range and paste diagonally using vba

How to copy an Array to an Excel Range in C#?

How to copy destination to source on OnRenderImage