+ Reply to Thread
Results 1 to 8 of 8

MIN & MAX VBA commands not seeming to work

  1. #1
    Registered User
    Join Date
    11-11-2009
    Location
    Columbus, Ohio; USA
    MS-Off Ver
    Excel 2002
    Posts
    70

    Wink MIN & MAX VBA commands not seeming to work

    Could someone check out the VBA code here?

    I would like someone to explain the reason why when the program is run, the maximum value in column S successfully is selected by being colored in pink, but the minimum in column R between those pink max's (indicated by the entire row outlined in red) is not the minimum.

    In other words, look at the numbers in column R. Only the 14.08 rows are supposed to be boxed in red. I can't understand why the 30.08 and the 46.08 are boxed in red??? And puzzling to me is why the 46.08 near the top are boxed, yet the 46.08 near the bottom are not boxed.

    Thank you!

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Danexcel; 12-08-2009 at 03:42 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: MIN & MAX VBA commands not seeming to work

    Just a quick heads up, it's possible DstRng is incorrect depending on active sheet at run time given you're not fully qualifying, ie I suspect it should be:

    Please Login or Register  to view this content.
    That said I've not looked at your file... but I suspect the above requires correction nonetheless.

  3. #3
    Registered User
    Join Date
    11-11-2009
    Location
    Columbus, Ohio; USA
    MS-Off Ver
    Excel 2002
    Posts
    70

    Re: MIN & MAX VBA commands not seeming to work

    Quote Originally Posted by DonkeyOte View Post
    Just a quick heads up, it's possible DstRng is incorrect depending on active sheet at run time given you're not fully qualifying, ie I suspect it should be:

    Please Login or Register  to view this content.
    That said I've not looked at your file... but I suspect the above requires correction nonetheless.

    Thanks for the information.
    I tried replacing the one line in the code with yours, but I got an error with that line as the problem.
    Was there another place I also needed to copy it into?

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: MIN & MAX VBA commands not seeming to work

    For whatever reason I failed to encase the range within quotations...

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: MIN & MAX VBA commands not seeming to work

    OK I've just looked at this properly... try the below (I've tried not to adjust from your existing code unless nec.)

    Please Login or Register  to view this content.
    The key (IMO) is to establish the MIN for the MAX prior to commencing the Loop, this is done via the Evaluate.

  6. #6
    Registered User
    Join Date
    11-11-2009
    Location
    Columbus, Ohio; USA
    MS-Off Ver
    Excel 2002
    Posts
    70

    Re: MIN & MAX VBA commands not seeming to work

    I'm trying your suggested code now. Thank you!

    One thing I'd like to ask is, on the INPUT tab on the worksheet I only want the rows outlined in red from the DETAILS sheet to be listed. It seems now when I run your code nearly 300 lines show up on the INPUT page, when I really want only the actual handful of rows that are outlined in red from the DETAILS page.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: MIN & MAX VBA commands not seeming to work

    Given the way you're defining DstRng you need to resize it before using it as basis for paste, ie use:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-11-2009
    Location
    Columbus, Ohio; USA
    MS-Off Ver
    Excel 2002
    Posts
    70

    Re: MIN & MAX VBA commands not seeming to work

    Hello DonkeyOte,

    I've been busy but I swung back round to working on this. I originally did not know where to add the snippet you sent last, but I believe I figured it out, and I am getting better results. I will mark as solved for now!

    Thank you very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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