none
Move Array to sheet RRS feed

  • Question

  • hi

    I have 1 dimensional array  (called varTempTable) with 24 entries. I want to move the contents to a worksheet in 6 rows by 4 columns.

    I have tried this command

    DailyRepCrtSh.Range("E9").Resize(rowsize:=6, columnsize:=4) = varTempTable 

    but all i get is 6 rows with the contents of the first 4 cells. I don't using Transpose will help.

    Any ideas please?

    thanks,

    Peter

    Wednesday, September 27, 2017 2:45 PM

Answers

  • You cannot move a one-dimensional array to a two-dimensional range in one go. You have to loop through the elements. For example:

        Dim i As Long
        For i = 1 To 24
            DailyRepCrtSh.Cells((i - 1) Mod 6 + 9, (i - 1) \ 6 + 5).Value = varTempTable(i)
        Next i


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by py1 Thursday, September 28, 2017 7:25 AM
    Wednesday, September 27, 2017 5:38 PM

All replies

  • You cannot move a one-dimensional array to a two-dimensional range in one go. You have to loop through the elements. For example:

        Dim i As Long
        For i = 1 To 24
            DailyRepCrtSh.Cells((i - 1) Mod 6 + 9, (i - 1) \ 6 + 5).Value = varTempTable(i)
        Next i


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by py1 Thursday, September 28, 2017 7:25 AM
    Wednesday, September 27, 2017 5:38 PM
  • thanks Hans - i guessed that might be the case.
    Thursday, September 28, 2017 7:25 AM