+ Reply to Thread
Results 1 to 5 of 5

Small change to code to Locate Numbers

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

    Small change to code to Locate Numbers

    I have posted this question at Mr Excel but they could not help me due to not having an image and my unclear requirements (which I have corrected here).
    https://www.mrexcel.com/forum/excel-...e-count-2.html

    I was looking for help on adding on some code to find numbers 1 to 20 that have sets of numbers in the adjacent cell.. The code below works.

    Please Login or Register  to view this content.
    The code searches 3 ranges D3:D10, G12:G18, I1:I10 ((I will need to be able to add additional ranges in the future). There are numbers (ranging from 1 to 20) in each cell. What I require the code to do for a positive result is to check the cells to the adjacent right of each number in the range for set of numbers in them.

    So in my sample data cell D4 has number 7 in it but no set of numbers (2-2 or 99-1 etc.) in cell E4 it so that would be a negative result but in cell E5 which has 1 in it and a 1-1 in cell F5 that is a positive result and what needs to be counted and written to cell B2. The other two positive examples are cell G14 and cell I6. All threw would be counted as a positive result and written to cell B2. There will always be a set of numbers somewhere beside the ranges and so always have a positive result. The expected result is 3 in cell B2.

    The 3 cell range are formatted as general and the sets of numbers are formatted as text.

    That would do it. Thanks so much for all your help.

    find numbers.png

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Small change to code to Locate Numbers

    Could you perhaps just change the code to offset one column to the right?

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

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

    Re: Small change to code to Locate Numbers

    Hi

    Thanks for your reply. I understand what you're saying but I'm trying to count how many numbers in the cell range have adjacent cell data in them.

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Small change to code to Locate Numbers

    And the code above produces 3 in B2 so what's the issue?

    WBD

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

    Re: Small change to code to Locate Numbers

    Sorry for the delay in getting back to you. Your code works perfectly. I greatly appreciate it. If you have time/interest I have just posted another problem that I think is similar to this code but I’m not sure. You guys are the experts at this stuff. The post is titled” Code to add numbers”.
    Thank-you again.

    Christine

+ 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. Code to Locate Numbers and Write Results
    By scott1945 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-25-2019, 04:31 PM
  2. Code to Locate Numbers and Write Location
    By scott1945 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2019, 01:21 PM
  3. how to code a change in numbers
    By cavalerox in forum Excel General
    Replies: 7
    Last Post: 04-01-2018, 10:44 PM
  4. Replies: 8
    Last Post: 11-19-2014, 06:12 PM
  5. Replies: 12
    Last Post: 04-24-2011, 05:45 PM
  6. Replies: 1
    Last Post: 10-05-2010, 11:16 AM
  7. 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

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