1

I'd like to paste the value of an array to a column. I've read somewhere that if I use a 2D array is not necessary to use .Transpose. I've defined a variable LRow witch contains the total number of rows in the column, using this code

Windows("export").Activate
With Sheets("export")
    LRow = .Range("A" & .Rows.Count).End(xlUp).Row
End With

But than it seems not possible to use it to define the array like this

Dim copyArray(1 To LRow, 1 To 1)
copyArray = Worksheets("export").Range("A1:A" & LRow).Value
Windows("import").Activate
Worksheets("Foglio1").Range("A2:A" & LRow + 1) = copyArray
End Sub

I think it's because with this code I'm defining a static array.

I there any solution to this?

1 Answer 1

1

Try it as,

dim copyArray as variant
with worksheets("export")
    copyArray = .range(.cells(1, "A"), .cells(.rows.count, "A").end(xlup)).value
end with
Worksheets("Foglio1").Range("A2").resize(ubound(copyArray, 1), ubound(copyArray, 2)) = copyArray

That always works for me and is more dynamic as the target is always reshaped to match the source.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.