+ Reply to Thread
Results 1 to 17 of 17

Array VBA Redim help.

  1. #1
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Array VBA Redim help.

    So I have this VBA code heavily modified from a source. Although the code looks complicated, I have this problem that I think could be solved in a simple manner (for experienced guys, at least :\ )

    Please Login or Register  to view this content.
    I needed it such that when I change the value of "nobs", it would give me the exact amount of 'observations' I need regardless of how many data points I use for VLE_FIT. Basically this means I am going to use the 'function method' in gathering the data points from the sheet, then resizing the array formed by the data points.

    Sadly, I always end up with an error. I don't know why does it keep on creating errors, I already made sure that the iterations for the array generation would end at 'nobs'. Basically this means on the "Const nobs As Integer = 201", when I change 201 to 25, it would only need the first 25 data points and would discard the rest. Care to look at this, anyone? I'd appreciate any form of help. Thanks!

    CROSS-POST LINK: http://www.mrexcel.com/forum/excel-q...edim-help.html
    Last edited by maistral; 12-20-2015 at 09:53 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Array VBA Redim help.

    I think this would work
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    Still didn't work It chucks out that annoying #VALUE! error.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Array VBA Redim help.

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    ==========
    Crosspost located here: http://www.mrexcel.com/forum/excel-q...edim-help.html
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    Okay, will do. I wasn't familiar with such a rule, sorry. I just really needed help.

    Edited the main post.
    Last edited by maistral; 12-20-2015 at 10:02 PM.

  6. #6
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    Posted an update on the other forum.
    http://www.mrexcel.com/forum/excel-q...im-help-2.html

    This is making me cry now. I followed all of your advices and it still chucks out the retarded #VALUE! error.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Array VBA Redim help.

    If an array variable is initially declared with explicit indices, it cannot be redeemed.

    Please Login or Register  to view this content.
    if you anticipate redeeming an array, initially declare it without any indices.

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  8. #8
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    Now I'm beginning to understand why cross-posting is wrong lol. I am really, really sorry.

    I got that 'initially declare without any indices' fixed already, and it still is printing out the #VALUE! error.

    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Array VBA Redim help.

    (How to) Upload a Workbook directly to the Forum
    (please do not post pictures or links to worksheets)
    • Click Advanced (next to quick post),
    • Scroll down until you see "Manage Attachments",
    • Click that then select "add files" (top right corner).
    • Click "Select Files" find your file, click "open" click "upload"
    • Once the upload is completed the file name will appear below the input boxes in this window.
    • Click "Done" at bottom right to close the Attachment Manager.
    • Click "Submit Reply"
    Note: Please do not attach password protected workbooks/worksheets
    Ben Van Johnson

  10. #10
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    This is my attachment.lm trial 5.xlsm

  11. #11
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    This is an updated attachment. Cross-posted from here: http://www.mrexcel.com/forum/excel-q...ml#post4375572

    lm trial 6.xlsm

  12. #12
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Array VBA Redim help.

    I made the following changes which should get you closer:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    The program isn't iterating anymore. I'll figure out what happened.

    EDIT: It doesn't work. :\ the new array continually lists the parameters regardless of the value of nobs. This is so hard and is impossible to solve I guess (
    Last edited by maistral; 12-21-2015 at 04:20 AM.

  14. #14
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Array VBA Redim help.

    I just fix the VBA statement errors, now the attached file is run without error, but I don't know whether the result is correct or not, the formulas seemed alien to me.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    HOLY ****

    YOU FIXED IT. And I was down the whole day thinking it was impossible. My problem is solved now. Thanks a lot!

  16. #16
    Registered User
    Join Date
    02-15-2013
    Location
    Manila, Philippines
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Array VBA Redim help.

    Thanks for all your efforts guys, needless to say all your inputs are valuable as I'm still quite new to most of the array functions, and sorry about the inconveniences made about the cross-posting.

    And I can't stop grinning. :D

  17. #17
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Array VBA Redim help.

    You are welcome, and many thanks for the reputation points.


    Regards

+ 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] Redim array - out of range
    By michson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2015, 03:51 AM
  2. [SOLVED] Redim an array 2 dimensions
    By mortphil in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-28-2014, 10:09 AM
  3. Using the ReDim array function in a multidimensional array in excel
    By Doruli in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2012, 01:43 PM
  4. Redim 2 dimensional array
    By efernandes67 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-10-2011, 10:38 AM
  5. Assign sheet value to array... and redim the array size
    By Orange.CL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2010, 07:18 AM
  6. ReDim Array
    By Viktor Ygdorff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2006, 11:09 AM
  7. ReDim Object array as parameter of Variant array
    By Peter T in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-10-2005, 10:06 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