+ Reply to Thread
Results 1 to 6 of 6

Array In VBA Formula ... "Subscript out of range"

  1. #1
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Array In VBA Formula ... "Subscript out of range"

    I've written the code below, but am getting a "subscript out of range" error at the line in bold. My array is working (I checked it earlier by populating it into a range to test), so I'm wondering if there's some syntax issue with that bolded part.

    What I'm trying to do there is multiply every item in column L by element 1 in my array, and populate that result in Column M.

    Array Sample.xlsx

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Array In VBA Formula ... "Subscript out of range"

    I am getting a type mismatch, not subscript out of range. You are trying to multiply a scalar value (the Percent) times an array and that doesn't make sense. Maybe you want to multiply each element of the array times Percent.
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Array In VBA Formula ... "Subscript out of range"

    Hmm...Percent actually is the array. I used a user defined type and Percent refers to the second column on the DMA tab. Basically I want to multiply every cell in that range by a particular percent within the array.

  4. #4
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Array In VBA Formula ... "Subscript out of range"

    Just got a chance to test out the correction...that works perfectly. Exactly what I was trying to do. Thanks!

  5. #5
    Forum Contributor
    Join Date
    02-15-2012
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Array In VBA Formula ... "Subscript out of range"

    Actually, here's a follow-up question: Is there anyway to do this without using a loop? The real version of this data is very lengthy (tens of thousands of rows)...

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Array In VBA Formula ... "Subscript out of range"

    perhaps
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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. Error msgs: "Object varible or with block variable not set"; "subscript out of range"
    By menyanthe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-26-2009, 04:58 PM
  2. [SOLVED] Find method fails in Excel 2003 ("Subscript out of range")
    By Guy Jara in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2006, 12:10 AM
  3. If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ...
    By Maria J-son in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2006, 08:25 AM
  4. [SOLVED] "Subscript out of range" error for: Workbooks("Test1.xls").Save
    By Just12341234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2005, 11:05 AM
  5. [SOLVED] FileCopy Command Giving "Subscript Out of Range" Error Message
    By Jim Hagan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2005, 02:05 PM

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