0

I have created an array in VB and want to copy the whole array to an excel spreadsheet rather than doing it a line at a time. This will make the process much quicker.

The array code at VB end is like as follows

xlWorkSheet.Range("A2").Resize(x, y).Value = MyArray

The excel spreadsheet has headings

Name, Dept, Salary

Rather than being displayed as

Name     Dept        Salary
Smith    Accounts    10000
Green    Sales       14500 
Brown    Accounts    12000

It is getting displayed as

Name       Dept   Salary
Smith      Green  Brown
Accounts   Sales  Accounts
10000      14500  12000
Mike67
  • 11,175
  • 2
  • 7
  • 15
Arfin
  • 5
  • 4
  • *This will make the process much quicker* - really? How do you know? Where is the slow inefficient code right now (it's not in your question)? Looks like the simplest thing would be to create your array the other way round? Where's the code that creates the array (it's not in your question either) ? – Caius Jard Aug 26 '20 at 09:24
  • Please read up on how to post monospace preformatted text on SO; you keep rolling back other people's edits to make your post readable, reverting their sensible edits into this unreadable mess – Caius Jard Aug 26 '20 at 12:33
  • You need to fix the array or transpose the data in excel: https://stackoverflow.com/questions/13174916/transpose-a-range-in-vba – Mike67 Aug 27 '20 at 01:04
  • Thanks mike, transpose worked for me – Arfin Sep 01 '20 at 14:46

0 Answers0