PDA

View Full Version : Dynamically change size of Array



Djblois
04-28-2010, 11:46 AM
Someone on here gave me this code to try so that I can find the size of an array and fill headings in based on the size of the Array. However it is not working. Here is the code that I am trying:

Sub comAddColHeadings(ParamArray arrHeadings() As Variant)

Range("A1").Resize(, UBound(arrHeadings) - LBound(arrHeadings) + 1).Value = arrHeadings

End Sub

What it is supposed to do is:
1) I call that sub with the Headings that I want to use
2) It determines the size of the Array
3) it fills the amount of cells across based on the Size of the Array

however nothing is coming out but it is not crashing either.

Bob Phillips
04-28-2010, 12:31 PM
It works fine for me Daniel, it populates the headings as expected.

Djblois
04-28-2010, 12:35 PM
Have any idea why it will not work for me?

I did set up a watch and it the Array did work correctly.

Bob Phillips
04-28-2010, 01:12 PM
Have you a workbook where it doesn't work?

Djblois
04-29-2010, 05:23 AM
it is no specific workbook, I use it in an add-in that people use on many files - and it will not work on any of them

Djblois
04-29-2010, 07:58 AM
In the watch window it shows that it is not empty but when I hover over the code this shows up: