E
eholz1
Hello Again,
And thanks,
I am trying to write strings from an array to a range on a worksheet.
I must be missing something.
the array is dynamic and I use ReDim Preserve to load the contents.
I have 6 strings in the array. I want to write the data in one
column.
Code snippet:
Dim SheetsProcessed as Range
Dim i as Integer
(the array is set in a different module, and marked as Public
sheetsArray() as Variant"
'displays list of sheets processed and evaluated
Set SheetsProcessed = Range("K2", "K" & UBound(sheetsArray)+1)
SheetsProcessed.Name = "processed"
Range("processed").Value = sheetsArray ' this writes only the first
array element
For i = LBound(sheetsArray) To UBound(sheetsArray)
Range("K" & 2 + (i + 1)).Value = sheetsArray(i) ' this writes
each
value in the cell
Next i
The line above Range("processed").value = sheetsArray places the
first
element in the array in 6 cells on the worksheet.
If I change the line to: SheetsProcessed.Value = sheetsArray, I get
the same result as the Range("processed") line above.
I must be missing something here
Thanks,
eholz1
And thanks,
I am trying to write strings from an array to a range on a worksheet.
I must be missing something.
the array is dynamic and I use ReDim Preserve to load the contents.
I have 6 strings in the array. I want to write the data in one
column.
Code snippet:
Dim SheetsProcessed as Range
Dim i as Integer
(the array is set in a different module, and marked as Public
sheetsArray() as Variant"
'displays list of sheets processed and evaluated
Set SheetsProcessed = Range("K2", "K" & UBound(sheetsArray)+1)
SheetsProcessed.Name = "processed"
Range("processed").Value = sheetsArray ' this writes only the first
array element
For i = LBound(sheetsArray) To UBound(sheetsArray)
Range("K" & 2 + (i + 1)).Value = sheetsArray(i) ' this writes
each
value in the cell
Next i
The line above Range("processed").value = sheetsArray places the
first
element in the array in 6 cells on the worksheet.
If I change the line to: SheetsProcessed.Value = sheetsArray, I get
the same result as the Range("processed") line above.
I must be missing something here
Thanks,
eholz1