Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 37

Thread: Check if a cell contains same digits

  1. #11
    Board Regular kelly mort's Avatar
    Join Date
    Apr 2017
    Location
    Suhum, Ghana, West Africa
    Posts
    1,509
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Check if a cell contains same digits

    Quote Originally Posted by Peter_SSs View Post
    Something like

    Code:
    MsgBox Range("A1").Text = String(4, Left(Range("A1").Text, 1))
    Hi again,
    Sorry to wake this thread up again.

    But is there a way to verify with numbers like this:
    0123
    1234
    2345
    3456
    4567
    Etc?
    There Is Always A Better Way

  2. #12
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,976
    Post Thanks / Like
    Mentioned
    90 Post(s)
    Tagged
    21 Thread(s)

    Default Re: Check if a cell contains same digits

    Quote Originally Posted by kelly mort View Post
    is there a way to verify with numbers like this:
    0123
    1234
    2345
    3456
    4567
    Etc?
    Verify what?
    - That they are all 4 digits exactly?
    - That they are 4 consecutive ascending digits?
    - That every digit of 1234 is 1 more than every digit of the previous number (0123) etc?
    - Something else?
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the # key in the Reply window
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

  3. #13
    Board Regular kelly mort's Avatar
    Join Date
    Apr 2017
    Location
    Suhum, Ghana, West Africa
    Posts
    1,509
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Check if a cell contains same digits

    Yes to all the above but nothing else
    Last edited by kelly mort; Aug 24th, 2019 at 03:44 AM.
    There Is Always A Better Way

  4. #14
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,976
    Post Thanks / Like
    Mentioned
    90 Post(s)
    Tagged
    21 Thread(s)

    Default Re: Check if a cell contains same digits

    Quote Originally Posted by kelly mort View Post
    Yes to all the above but nothing else
    Really?

    So this is nothing like the previous question?

    This time, instead of looking at the cells individually, we have to look at a number of cells as a group and this example would fail the verification?

    Verify

    A
    10123
    23456
    31234
    42345


    Excel tables to the web >> Excel Jeanie HTML 4


    Further, the maximum number of cells that could fit the verification is 7 and that would be these 7 cells?

    Verify

    A
    10123
    21234
    32345
    43456
    54567
    65678
    76789


    Excel tables to the web >> Excel Jeanie HTML 4

    .. or perhaps you misunderstood what I was asking with my third point?
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the # key in the Reply window
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

  5. #15
    Board Regular kelly mort's Avatar
    Join Date
    Apr 2017
    Location
    Suhum, Ghana, West Africa
    Posts
    1,509
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Check if a cell contains same digits

    Sorry I think my explanation was not clear:
    This is a new form to put it; I will always have the code look at cell A1.
    Then in that cell we are looking for any of those numbers as listed above. Then throw the msgbox as before. I hope this makes it clearer
    There Is Always A Better Way

  6. #16
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,976
    Post Thanks / Like
    Mentioned
    90 Post(s)
    Tagged
    21 Thread(s)

    Default Re: Check if a cell contains same digits

    Quote Originally Posted by kelly mort View Post
    I will always have the code look at cell A1.
    Then in that cell we are looking for any of those numbers as listed above.
    So, just like data validation?
    Except that "those numbers as listed above" finish with "Etc".
    Where does the "Etc" end? What is the full list of valid numbers? Is it just the 7 numbers I listed in my second screen shot in post 14?
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the # key in the Reply window
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

  7. #17
    Board Regular kelly mort's Avatar
    Join Date
    Apr 2017
    Location
    Suhum, Ghana, West Africa
    Posts
    1,509
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Check if a cell contains same digits

    -The full list of the numbers is supposed to be unlimited ; any number with the consecutive number form of "ABCD" is part of the list.
    - "Etc" is not part of the list I used it there to show the sequence


    So in cell A1, if the number has the form ABCD like 0123, 1234, ... Then we call the msgbox
    There Is Always A Better Way

  8. #18
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,976
    Post Thanks / Like
    Mentioned
    90 Post(s)
    Tagged
    21 Thread(s)

    Default Re: Check if a cell contains same digits

    Quote Originally Posted by kelly mort View Post
    -The full list of the numbers is supposed to be unlimited ; any number with the consecutive number form of "ABCD" is part of the list.
    So there has to be 4 digits and they have to be consecutive.
    Unlimited list??
    I'm clearly not understanding. Could you give me one more example of a 4-digit number with consecutive digits other than those 7 examples in the bottom screen shot of post 14?

    Can you also confirm that the cell being looked at is formatted as Text, since 0123 would not normally show that leading zero?
    Last edited by Peter_SSs; Aug 24th, 2019 at 08:12 AM.
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the # key in the Reply window
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

  9. #19
    Board Regular kelly mort's Avatar
    Join Date
    Apr 2017
    Location
    Suhum, Ghana, West Africa
    Posts
    1,509
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Check if a cell contains same digits

    Yes the format will be as text.

    Oh okay sorry. I think that's all the list you have up there. I didn't think through it well enough at first which made me think there could be infinite possibilities.

    Yes there should be four consecutive digits
    There Is Always A Better Way

  10. #20
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    40,976
    Post Thanks / Like
    Mentioned
    90 Post(s)
    Tagged
    21 Thread(s)

    Default Re: Check if a cell contains same digits

    Code:
    MsgBox InStr(1, "|0123|1234|2345|3456|4567|5678|6789|", "|" & Range("A1").Text & "|") > 0
    Edit: Safer would be
    Code:
    MsgBox InStr(1, Replace("|0123|1234|2345|3456|4567|5678|6789|", "|", Chr(0)), Chr(0) & Range("A1").Text & Chr(0)) > 0
    Last edited by Peter_SSs; Aug 24th, 2019 at 08:55 AM.
    Hope this helps, good luck.
    Peter
    Excel 365 - Windows 10
    - Want to help your helpers by posting a small, copyable, screen shot directly in your post? Look here
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the # key in the Reply window
    - Read: Forum Rules, Forum Use Guidelines, & FAQ

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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