Consulting

Results 1 to 7 of 7

Thread: How to Declare Public Multi-Dimension Arrays

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    VBAX Regular
    Joined
    May 2004
    Location
    Sydney, Australia
    Posts
    36
    Location
    Hi James,

    You're surrounding each of your constants with " marks. Therefore VBA is creating an array of strings; this is what it looks like when you loop through each element in the array:-

    Sub Test()
        Dim arrayRenewalControlNames
        Dim i As Long
        arrayRenewalControlNames = Array("DAY180", "DAY120", "DAY90", "DAY60", "DAY30", "EXPIRE_DAY")
        For i = LBound(arrayRenewalControlNames) To UBound(arrayRenewalControlNames)
            Debug.Print arrayRenewalControlNames(i)
        Next
    End Sub
    Results:-

    DAY180
    DAY120
    DAY90
    DAY60
    DAY30
    EXPIRE_DAY

    If you remove the speech marks then the array will be created with the numeric values that you need e.g.

    arrayRenewalControlNames = Array(DAY180, DAY120, DAY90, DAY60, DAY30, EXPIRE_DAY)
    Results:-

    180
    120
    90
    60
    30
    1


    HTH
    Dan
    Last edited by Aussiebear; 05-10-2025 at 04:23 PM.

Posting Permissions

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