Consulting

Results 1 to 5 of 5

Thread: Solved: Kangaroo Problem

  1. #1

    Talking Solved: Kangaroo Problem

    Okay here's one you might enjoy. I've got a kangaroo population simulator. I have to have values printed to a worksheet through a UserForm, and a real-time chart. There is one problem, and that is that when I specify a number of months to compute, it computes (Mnth = Mnth - 1). I know this is the root of my problem, but fixing it is a whole different story. If I just code (Mnth = Mnth) and take out the "-1", it errors on me. I've tried a few other things but I hit a brick wall every time.

    Thanks!

  2. #2
    VBAX Regular bodhi's Avatar
    Joined
    Nov 2005
    Posts
    13
    Location
    SilverBack,

    you have used redim to reallocate storage space for your array variables 'km', 'kf', 'dm', & 'df' to a length of 1 to Mnt.

    Further into your code you try and assign a value outside of this array length. try :

    [VBA]ReDim km(1 To Mnt + 1)
    ReDim kf(1 To Mnt + 1)
    ReDim dm(1 To Mnt + 1)
    ReDim df(1 To Mnt + 1)[/VBA]

    this will give you one more position in your array and should solve your problem.


  3. #3
    I did what you suggested. The new code is attached. I still fall one short

  4. #4

    Talking

    Heheh, talk about being too close to the forest to see the trees! I figured it out. I had to [vba]redim mnt (1 to mnt + 1)[/vba] which allowed me to change the [vba] For j=1 to mnt - 1 [/vba] to [vba] For j=1 to mnt[/vba]

    Anyway, thanks again!

  5. #5
    VBAX Regular bodhi's Avatar
    Joined
    Nov 2005
    Posts
    13
    Location
    I should have explained it a little further but i am glad that you solved the probelm.

Posting Permissions

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