+ Reply to Thread
Results 1 to 17 of 17

Locate Numbers 26 and higher

  1. #1
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Locate Numbers 26 and higher

    I have some code that searches a range and does a count of the values and writes the results to cell A18.

    Please Login or Register  to view this content.
    I need to make a change to the code to search the ranges but look for values over 25 and write the results to cells B3, B4, B5 or B6. Some ranges may or may not have sets of numbers in them. I’m only interested in sets of numbers that have a value of 26 (2nd number in set) or higher in them. An example would be 8-26 or 7-35. Below is sample data and when I’m finished designing my sheet it will have data above, below the search ranges. See example below with expected result.

    General Notes:

    - I can not use a formula because their are issues with some other VBA code I run in the same cell range.
    - I need hard code for the search ranges (I have many ranges in different locations on the sheet) so I can add or delete in the code.
    - The sheet name is Sheet 1 and their is only one sheet in the workbook.
    - Using Excel 2007.
    - The search range cells are formatted as text.
    - The write cells are formatted as general.


    Sample data:

    The code searches ranges D3:D12, F3:F12, H3:H12 for sets of numbers that are over 26 or higher. The first found set of numbers would be 10-26 in cell E9 and the 2nnd positive set of numbers would be 5-35 located in cell F10. The code would then write the cell location to cells B3, B4, B5 or B6. If their are NO positive results could the code write a 0 in each of the four cells.

    If you have any questions please ask so I can clarify any issue(s). Thanks so much for all your help.
    Attached Images Attached Images
    Last edited by CHRISTINEKENDALL93; 07-03-2019 at 11:11 AM. Reason: wrong sheet

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Tricky as your attachment seems to not reflect your explanation & picture …

  3. #3
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Locate Numbers 26 and higher

    The correct Excel sheet has been uploaded, thanks.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Locate Numbers 26 and higher

    Going by Post #1. Have not opened attachment.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Locate Numbers 26 and higher

    Hi jolivanes

    Thank-you for your reply and code. Your code works but it's not writing anywhere on my real sheet. It looks really good but I may owe you an apology as I didn't specify that I need the code to write to hard coded cells. In my sample data above to cells B3:B6. I'm hoping I haven't caused a big problem. Sorry

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Locate Numbers 26 and higher

    The code looks for the first empty cell below B3 so if you have anything below B6 it could be anywhere in Column B (Below B6 anyway). Check to the end of Column B.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Locate Numbers 26 and higher

    For the specific range to paste the addresses into, try this.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Locate Numbers 26 and higher

    Thank-you again for the code. The issue I have is I’m still designing my sheet and your code works today but next week when I have to made a design change it will not work or will overwrite something I require.

    I really have to have hard code so I can control where the write occurs and I can easily make the necessary changes. You are very proficient in your code writing I on the other hand am not and would have a lot of trouble make the necessary changes. If at all possible can we make the necessary change to the code? Thanks very much.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Locate Numbers 26 and higher

    Which part of the supplied suggestion are you referring to?
    Have you tried the code? It is "hard coded"

    An explanation might help.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 07-04-2019 at 11:44 AM. Reason: explanation

  10. #10
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Locate Numbers 26 and higher

    Thank-you so much for the explanation, now I get it. The code works perfect. A last request, if possible: if their are no values over 25 can you have have the code write a zero in the first cell (B3 in the sample above) that is used to write a positive result if their is one?

    Again, thank-you

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Locate Numbers 26 and higher

    I don't quite get that. You are checking 3 ranges with 10 cells in each range which relates to a possible 30 cell addresses. This obviously is not the case because you have only four cells to enter the possible addresses.
    Maybe explain the relationships.
    Also let us know when to change from Cell B3 to B4, and B5 and/or B6, even if there is no Cell Address to be entered.
    If there are no addresses at all to be entered you can add this to the bottom of the code (just before "End Sub")
    Please Login or Register  to view this content.
    Last edited by jolivanes; 07-04-2019 at 04:23 PM.

  12. #12
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: Locate Numbers 26 and higher

    Because of these unexplained relationships I keep my code on my side
    ('cause too of the previous post as same 'issues' within this one) …

    I wanna know for example if there are 10 data in the search ranges and 7 values are matching so what happens ?!
    Still always data in the 4 cells in B3:B6 only ?

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Locate Numbers 26 and higher

    Hey Marc.
    Don't hold back. I'm learning also.

  14. #14
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    See the forum rules to learn how to well create a thread …

    Any answer to post #11 & 12 ?‼
    Last edited by Marc L; 07-05-2019 at 06:22 AM.

  15. #15
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Locate Numbers 26 and higher

    Hi jolivanes

    I just finished testing and it all works great. Thank-you so much for all your help it’s greatly appreciated.
    Christine

  16. #16
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Locate Numbers 26 and higher

    Hi Marc L

    I can see why you would have trouble with my explanation. It should have read that I only expect 1 occurrence of over 25 therefore having 4 cells to write would be adequate, my fault. When jolivanes posted an explanation of his code that made all the difference and I highly recommend this to all who read this post. For most of us we are not that technical VBA readers so it really make a huge difference in understanding code that is written. VBA is like leaning a foreign language, hard in the beginning but easy when you understand the issues.

    Christine

  17. #17
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831
    Jolivanes, private message sent !

    Christine,
    to understand why this 4 fixed cells we post questions in order to clarify your need
    - so nothing to do about VBA but just about explaining clearly your need - and we had no answer …
    What if 10 cells with data and 7 are matching, what must be the result and where ?
    Last edited by Marc L; 07-05-2019 at 11:52 AM. Reason: typo …

+ 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] Random Numbers Attempts Must Be Higher Than Made
    By xjohnson in forum Excel General
    Replies: 3
    Last Post: 12-10-2018, 02:00 PM
  2. Replies: 7
    Last Post: 03-23-2018, 08:27 PM
  3. possible to locate higher hierarchical list of HTML code?
    By lubbamkt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-03-2014, 09:27 AM
  4. [SOLVED] The user cannot type in numbers higher than 20. How to prevent him from doing that?
    By Shishek in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-04-2013, 09:48 AM
  5. [SOLVED] Look at Range of numbers and return the next number higher than x
    By gonhikin in forum Excel General
    Replies: 3
    Last Post: 12-07-2012, 12:07 PM
  6. Locate two equal numbers in an array of numbers
    By avveerkar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2010, 01:22 AM
  7. Can I flag numbers that are higher/lower than a range of #'s
    By Rick Parker in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-07-2006, 09:00 PM

Tags for this Thread

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