+ Reply to Thread
Results 1 to 5 of 5

"constant expression required" error given when setting up an array

  1. #1
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    "constant expression required" error given when setting up an array

    Trying to set up an array, but get "constant expression required" error with bars_qty highlighted on the last line. Any idea what's causing this?

    Please Login or Register  to view this content.
    You either quit or become really good at it. There are no other choices.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: "constant expression required" error given when setting up an array

    Looks like you can't use a variable in a Dim statement.

    See if
    Please Login or Register  to view this content.
    works instead.
    Last edited by MarvinP; 04-27-2017 at 11:58 AM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: "constant expression required" error given when setting up an array

    Hi,

    You can only resize a dynamic array using a variable. So either use a constant thus
    Please Login or Register  to view this content.
    or a dynamic array
    Please Login or Register  to view this content.
    The initial Dim statement is optional here.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    Re: "constant expression required" error given when setting up an array

    Quote Originally Posted by xlnitwit View Post
    Hi,

    You can only resize a dynamic array using a variable. So either use a constant thus
    Please Login or Register  to view this content.
    or a dynamic array
    Please Login or Register  to view this content.
    The initial Dim statement is optional here.
    Great! That works.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: "constant expression required" error given when setting up an array

    You're welcome and thank you both for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Compile Error Constant Expression Required
    By dloskot in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2016, 02:46 PM
  2. [SOLVED] Setting a range variable to its offset triggers an "Object required" error
    By Durarara in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-27-2016, 01:50 PM
  3. [SOLVED] "ByRef:mismatch" and "Constant Expression Required" Errors
    By Mishil in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-10-2015, 06:47 PM
  4. [SOLVED] How to assign a ImputBox to a "Constant expression"
    By capson in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-26-2014, 12:19 PM
  5. Compile error (Constant expression required) when using macro twice
    By flunzy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-02-2014, 10:35 AM
  6. [SOLVED] Find expression causing "Subscript out of range" error
    By aseret in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-08-2013, 12:05 AM
  7. [SOLVED] Compile error: Constant expression required error when merging two Codes
    By Kezwick in forum Outlook Programming / VBA / Macros
    Replies: 8
    Last Post: 06-26-2013, 09:32 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1