+ Reply to Thread
Results 1 to 23 of 23

Find the max value in a column and do looping

  1. #1
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Find the max value in a column and do looping

    ................................
    Last edited by Martin Lorentzen; 01-15-2016 at 03:00 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    Do you have headings? When the looping stops, what do you want to have done? Highlight the values used - show a message about the values chosen? Show the value that does not fit? And where is the max capacity value stored, or is it an input from the user? Anyway, looping is done like this


    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    ................................
    Last edited by Martin Lorentzen; 01-15-2016 at 03:01 PM.

  4. #4
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    Would be so cool if you could adjust the code with the new information, and then i could try to build on it myself.

    Or maybe some other expert would like to help?

    Have a good day!

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    Thank you Bernie, it is much appreciated.

    Please Login or Register  to view this content.
    Though i get an error 13 mismatch on this line, so it seems one of the variables should be another type? I tried changing it a bit, but doesn't seem to work.

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    Is it possible that you have blanks in your columns? This should work....

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    ................................
    Last edited by Martin Lorentzen; 01-15-2016 at 03:01 PM.

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    Because the max wasn't reached.

    Change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    Perfect. It works. I will change it to solved. Thanks again!

  11. #11
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    Hi. I am just coming back to this code again. The below code works perfectly, but it only executes in the active sheet and i want it to execute in all my sheets.

    Is there a simple way to add that?

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    Perfect. You are the best!

    Let's say that instead of picking the largest value, it should just pick a random (positive 0<) cell in the same range, and afterwards do the same looping. Would that need a lot of changing in the codes?
    Last edited by Martin Lorentzen; 01-14-2016 at 12:36 PM.

  14. #14
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    Hmm, this is weird. My excel goes into "not responding" every time i try to run the code?

  16. #16
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    Can you post a (sanitized if needed) version of your workbook that shows the behavior?

  17. #17
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    But I just made a new module and posted the exact same code you did in there. There is nothing else. Only in the other modules, but that shouldn't have any effect on it right? Since I am only running this one

  18. #18
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    ................................
    Last edited by Martin Lorentzen; 01-15-2016 at 03:00 PM.

  19. #19
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    The code below works fine for me - here it is in a working workbook:

    Book4.xlsm


    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 01-14-2016 at 03:28 PM.

  20. #20
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    Hmm that is so weird. Did you try running the code in my sample file, does it work for you there?

  21. #21
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    I think it has something to do with the max capacity. I tried copying line after line into your sheet, it could do exactly the same until i copied all of row 4 into your workbook, then it gave the same error.

    So the error lies within row 4, but what it is i dont know :/

  22. #22
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,350

    Re: Find the max value in a column and do looping

    The issue was that the find needed to be forced to look at whole values

    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    01-12-2016
    Location
    London
    MS-Off Ver
    2010
    Posts
    24

    Re: Find the max value in a column and do looping

    Thank you so much Bernie. You are so cool Setting to solved again

+ 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] Using FIND and looping from bottom to top
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2015, 11:22 PM
  2. Looping with find and replace
    By Monkihunta in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-23-2015, 04:50 PM
  3. Looping to find multiple maximums within one column
    By phoenix1856 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-05-2013, 01:12 PM
  4. Looping through a column to find maximum repeated value
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2013, 07:02 AM
  5. [SOLVED] Looping Find Function
    By hkayani08 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-02-2012, 10:05 AM
  6. Looping Find
    By Gus80 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2008, 06:34 PM
  7. Looping the Find Function
    By maverick_abhi in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2007, 01:54 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