1

I am trying to dump the content of an array of Doubles into a single Cell in Excel with VBA.

I found an Answer, which solves the problem for Strings or Variant, but not for Double.

Dim arr(1 To 3) As Double
arr(1) = 0.81
arr(2) = 0.95
arr(3) = 1.74

Worksheets("Test").Cells(1,1).Value = dump(arr, ";")

The Last line should write all the values from the Array to the Cell specified.

Edit: Changed 0,81 to 0.81 etc. (German System vs. International Standard)

Tidoni
  • 195
  • 1
  • 4
  • 13
  • 1
    Just loop and concatenate the values into a string with whatever delimiter you want. – Rory Jul 15 '19 at 10:32
  • 3
    `Join(WorksheetFunction.Index(arr, 1, 0), ";")` – omegastripes Jul 15 '19 at 10:38
  • The original code also works properly. Simply replace "dump" with "Join" and change formatting of your numbers (dots instead of commas); array as Variant. Result: `0.81;0.95;1.74` – Justyna MK Jul 15 '19 at 10:40

1 Answers1

2

It will be a string anyway, looping or transposing or Use of Index(nice omegastripes): (plus change the , to .)

Dim arr(1 To 3) As Double
arr(1) = 0.81
arr(2) = 0.95
arr(3) = 0.74

Worksheets("Test").Cells(1, 1).Value = Join(Application.Transpose(Application.Transpose(arr)), ";")
EvR
  • 3,418
  • 2
  • 13
  • 23