Consulting

Results 1 to 6 of 6

Thread: Dynamically change size of Array

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Dynamically change size of Array

    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:

    [VBA]Sub comAddColHeadings(ParamArray arrHeadings() As Variant)

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

    End Sub[/VBA]

    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.
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It works fine for me Daniel, it populates the headings as expected.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Have any idea why it will not work for me?

    I did set up a watch and it the Array did work correctly.
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Have you a workbook where it doesn't work?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    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
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  6. #6
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    In the watch window it shows that it is not empty but when I hover over the code this shows up:
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •