+ Reply to Thread
Results 1 to 9 of 9

.find Function Failing

  1. #1
    Registered User
    Join Date
    02-20-2013
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2010
    Posts
    52

    .find Function Failing

    Excel Forum,

    I am searching for the row number of a cell in column A that contains a specific value. My code is returning errors and after researching the issue I am still at a loss. I have tried cutting and pasting other programmers' code into my worksheet but that still fails. Any help will be greatly appreciated.

    Below is my code and attached is the spreadsheet I am searching in. The portion that is failing me is in bold.

    Thank you for your help.


    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: .find Function Failing

    Hi, Centexcel,

    the bolded code alone works okay and displays Row 17.

    No sheet named "12 mo inc det" in the attachment, no code either - so Iīm not sure why your code would raise an error if the requirement like appropriate sheet are met.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    02-20-2013
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: .find Function Failing

    Holger,

    Thank you for your reply. I run the code and it produces a msgbox "not found."

    I cannot figure out why my code runs differently in different sheets. Any ideas? Thank you for your time.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: .find Function Failing

    This one works

    Please Login or Register  to view this content.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: .find Function Failing

    Hi, Centexcel,

    I run the code and it produces a msgbox "not found."
    I changed from Number to Number as Text with preceeding ' - found. I changed 4010 to be result of a formula - found.

    Code for me is located in a standard module - where did you place your code?

    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    02-20-2013
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: .find Function Failing

    Thank you so much!

    What does the columns(1) do for the function? Does it point the find function to A:A and then .find executes?

    Thanks again, you've made my day!

  7. #7
    Registered User
    Join Date
    02-20-2013
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: .find Function Failing

    Holger, I put my code in a standard module.
    Can you explain how you changed number to number as text in the code?

    Thank you for all your help.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: .find Function Failing

    Yes
    Range("A:A") is another option

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: .find Function Failing

    Hi, Centexcel,

    Number as Text:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In the code you provided you select a sheet, do some Copy&Paste and then do the search - maybe thatīs the key to why you wonīt find the item on other sheets.

    keyrange builds up the correct area: $A$1:$A$291 - one of the first checks I did on the code. No need to go for a full column there IMHO.

    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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