Identify and number Patterns

  • Re: Identify and number Patterns


    I have superseded the attachment in Post #180 with the following link.


    https://www.mediafire.com/?9oi160wvn3ug766 (8.14 mb)


    If you don't want to download, here are the macros, changes commented in upper case.



    snb was on the verge of a much better solution, but like Kjbox, I was getting debug in same place.

  • Re: Identify and number Patterns


    holycow


    The patterns that larbec gave in posts #176 and #178 are giving the same 400 error using your code as they do in my code. I am trying to see what the problem is, can you do the same?


    snb and I still looking at the array solution.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Identify and number Patterns


    maybe .. Must remember this is larbec thread. Holycow your solution has merit and works.
    larbec will beable to take the solution to his Excel class and it will be easily explained for his level of learning. The syntax and methods are within the conventions of any book he buys.

  • Re: Identify and number Patterns


    arrr man


    Error 400 in data #176 and #178 is because the Ifcount error .It shows 26 matches when there are zero . then the bug on specialcells


  • Re: Identify and number Patterns


    I was just about to post the same thing!


    Question is why should one number set in H3 bring up the 'No pattern matches' message when no match is found while another set does not?


    Also strange that the same error occurs with my filter method, while other non-matching patterns bring up the message ok.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Identify and number Patterns


    this should have caught it


    Code
    If Application.CountIf(Range("H12:H" & Range("H" & Rows.Count).End(xlUp).Row), Range("H3").Value) = 0 Then
            MsgBox "No matching patterns"
            Exit Sub
        End If
  • Re: Identify and number Patterns


    It does not because CountIf is returning 26 with this number set, not 0. A physical check of all data confirms it should be 0

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Identify and number Patterns


    So limitation of Excel COUNTIF.


    Bypass Excel


    Code
    If rng.Find(Range("H3").Value) Is Nothing Then
            MsgBox "No matching patterns"
            Exit Sub
        End If
  • Re: Identify and number Patterns


    Ooops


  • Re: Identify and number Patterns


    That sorted it for me.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Identify and number Patterns


    Just found one more small problem :)



    Sometimes .Value = .Value kicks in before all cells are populated and those remaining cells end up with 0 in them.


    Need to put an Application.Wait in here :( but not sure how long to put or if there's a better option.

  • Re: Identify and number Patterns


    try...

  • Re: Identify and number Patterns


    The following all works for me


  • Re: Identify and number Patterns


    I don't think it was larbec's bad, more of an excel limitation.


    I have done a little more bug proofing. Human nature is someone is going to press either the Run button or the Update button, either without entering anything in grid or with no data in the big list.


    Latest workbook here
    https://www.mediafire.com/?9oi160wvn3ug766 (8.17 mb)


    The amended macros


  • Re: Identify and number Patterns


    holycow


    Neat additions :)


    larbec


    Hope this finally gets a fully workable solution for you, enjoy working with it!


    You need only click the 'Update' button if you replace data or add more rows than you remove (or vise versa). The 'Run' macro checks that the last row of data is the same as the last row of the generated number set in column F, if not then column F is updated automatically. The 'Run' macro cannot tell if data has been changed without the total number of rows being altered, so if such a change has been made you need to click the 'Update' button after making the data change.


    May I suggest that, with the latest workbook uploaded by holycow (or whatever workbook you are using if you just amended the code) you highlight the full data set and standardise the formatting. Presently there are cells formatted as general, number and I am sure I even saw a text format in there somewhere. Format all to 'Number' with 0 decimal places. At the same time you could set all cells to the same font type and size and bold or regular, there is a mixture of all of those currently.


    To highlight the full data set go to cell F12, hold down CTRL and SHIFT, press the down arrow, then, still holding down CTRL+SHIFT, press the left arrow.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!