+ Reply to Thread
Results 1 to 5 of 5

If Statement for Cells.Find

  1. #1
    Registered User
    Join Date
    09-28-2019
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    9

    Cool If Statement for Cells.Find

    Hello,

    I have a snippet of code within my macro workbook to search for an item called LibraryKey within a veryhidden sheet. The macro works perfectly fine except for when I'm trying to solve for the IF statement (if LibraryKey isn't found aka a template doesn't exist for the userform request).

    Sample workbook with this my specific code in question is attached. I've separated this from the actual workbook (sensitive data) so you won't find some sheets that are referenced or the userform as well. This sub runs as a Private sub within a userform as a heads up.

    Goal: When I click the button to run this macro, if the LibraryKey is NOT found in the Library Sheet, then how can I display a message box or a populate a label within the userform that says "Template does not exist in the Library" and to go back to the userform? If the LibraryKey is found then proceed with the subroutine. The attempts I've tried render a Run-time error '91': Object Variable or With block variable not set

    Many thanks in advance.
    KeyboardQueen
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: If Statement for Cells.Find

    Maybe something like this, since you file is incomplete not able to test

    The red text is mine

    Please Login or Register  to view this content.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    09-28-2019
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    9

    Re: If Statement for Cells.Find

    Hello,

    Thank you for your efforts! This did not work. I'll have to get some more information shared so that we can do end to end testing with this. I'll probably do this after memorial day weekend when I have a chance.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: If Statement for Cells.Find

    You can add the file wijt the macro’s and Some dummy data

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: If Statement for Cells.Find

    Could you explain/expand your
    This did not work
    answer?
    It’s the same as phoning your house doctor and tell him/her “ it hurts when I press here” and can’t see you

+ 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. IF Statement To Find A Value
    By SamRam in forum Excel General
    Replies: 0
    Last Post: 07-03-2019, 12:08 AM
  2. [SOLVED] Not Returning Row Number With FIND statement When FIND should be valid
    By Jenn68 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2019, 02:22 PM
  3. [SOLVED] Find text in cell using cells object with-in IF Then statement
    By DevfromCorrie in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-07-2014, 02:50 AM
  4. If statement or Find statement?
    By Icehockey44 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-07-2013, 11:30 AM
  5. Find statement help when it doesn't find anything
    By hockeyadc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2012, 01:34 PM
  6. Have question about using .find statement and brackets around After:= statement
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-09-2011, 03:28 PM
  7. Stopping errors when a find statement doesn't find!
    By matpj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2006, 10:23 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