+ Reply to Thread
Results 1 to 10 of 10

Failing FIND method?

  1. #1
    Registered User
    Join Date
    11-28-2017
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    21

    Question Failing FIND method?

    Hello guys.

    I have a scenario where i need to set the interiour color of all cells in a sheet according to it's values.
    The correct color is stored in a list on another sheet and the value that represent the color is loaded into an array along with the colors long value.

    It works pretty well, except it won't set the color on cells that contain a formula instead of a value (despite lookin:=xlValues).
    Can you spot what might be wrong at the first glance of would you like me to attach the xlsx file?
    I don't understand why the code keeps ignoring it, despite that the fact that the FIND method is indeed finding the value.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Failing FIND method?

    Please Login or Register  to view this content.
    This skips the cells that have formula.
    Change something like
    Please Login or Register  to view this content.
    And
    Please Login or Register  to view this content.
    could be rewrite like
    Please Login or Register  to view this content.
    Last edited by jindon; 12-06-2017 at 05:37 AM.

  3. #3
    Registered User
    Join Date
    11-28-2017
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    21

    Re: Failing FIND method?

    Thats it!

    Well, almost.
    Making the first change you suggested would cause the code to run very slow (had to break).

    But removing the entire WITH statement did the trick!
    Thanks a lot for getting me on the right track.

  4. #4
    Registered User
    Join Date
    11-28-2017
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    21

    Re: Failing FIND method?

    Actually..
    I realized this code is backwards.

    The way its written now, it loads 257 variables into an array and then it searches each and every cell in the range for a match from those 257 variables.
    When i first wrote this, it was 16 variables, but now the code wont work anymore (it takes forever).
    Is there a way to do the other way around?
    Check every cell in range to see it the value in that cell exists in the array?
    Or as an alternative skip cells that are empty?
    The range should really be dynamic, but it can grow horizontally or vertically (or both) so i'm not sure which method to use last cell by rows of colums? Or it doesn't matter?

    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Failing FIND method?

    Too hard without seeing your workbook.

    Completely untested.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-28-2017
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    21

    Re: Failing FIND method?

    I understand it's rather hard to re-invent it just based on this. The "Colors" sheet is just a two column list and all "color identifiers" are max 3 chars.
    IŽll try your code out..

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-28-2017
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    21

    Red face Re: Failing FIND method?

    Well, that quickly went out or range. ^^

    I really appreciate your time. If you feel up for it, i've uploaded my WB on dropbox. (didn't manage to open the attach dialogue on this forum correctly)
    https://www.dropbox.com/s/behlyum1ny...ning.xlsm?dl=0

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Failing FIND method?

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Failing FIND method?

    One more change
    Insert one line
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-28-2017
    Location
    Sweden
    MS-Off Ver
    2016
    Posts
    21

    Re: Failing FIND method?

    Ah, that's right, or it will fail the regex when the case differs.
    I never though of using regex here, but your solution is much better than mine.
    It still takes a while if the area is huge but atleast it's doable.

    Thank you so much jindon! <3

+ 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. Workbooks.Open method failing to run
    By JasonLeisemann in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2013, 02:49 PM
  2. Select Method failing
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2011, 05:34 AM
  3. CELLS.Select method failing
    By ctmurray in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2008, 06:51 PM
  4. copy method of object failing
    By vj2india in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2006, 09:25 PM
  5. Select Method Failing
    By cmk18 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2005, 07:05 PM
  6. [SOLVED] Publish method failing, can't understand why
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2005, 03:05 PM
  7. [SOLVED] Excel Copy Method Failing.
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-11-2005, 01:06 PM
  8. add method of validation failing
    By mark kubicki in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2005, 04:06 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