+ Reply to Thread
Results 1 to 27 of 27

Code to find value in other worksheet in same workbook match with active cell

  1. #1
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Question Code to find value in other worksheet in same workbook match with active cell

    Hi All,

    I have written code to find matching value cell with my active cell using a search button. However it doesn't work.
    My code is

    Please Login or Register  to view this content.
    Last edited by diyVBA; 12-20-2019 at 02:06 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,319

    Re: Code to find value in other worksheet in same workbook match with active cell

    Is it because you're referring to two different worksheets?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    I corrected it, I get a new error now for the same line:

    Error 1004

    Application-defined or object defined error

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    Is it "Production Item" or "Production List" to go to ?
    - Battle without fear gives no glory - Just try

  5. #5
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    I corrected it,
    What is the new code ?

  6. #6
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    check the main code again

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,319

    Re: Code to find value in other worksheet in same workbook match with active cell

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  8. #8
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    attached,the copy (book1)
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    The code is OK else the loop uses fCell which is never refreshed !!

  10. #10
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    how can i fix it? why does it throw error 1004 in Application.goto statement?

  11. #11
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    Using
    Please Login or Register  to view this content.
    means you want to use the cell with name "firstAdd"
    There is no such cell in the sheet

  12. #12
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    Se to use
    Please Login or Register  to view this content.
    but still the comment concerning the loop !!!

  13. #13
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    how can i code it better, I am absolutely new with VBA. I want the person using Sched List worksheet to be able to find the record any number of times they want.

  14. #14
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    I actually just want the code to find the first match it finds and get out of the loop.

  15. #15
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    to be able to find the record any number of times they want.
    Is that means the record can exist several times in sheet "Production List" and you want to display all records ???

  16. #16
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    I actually just want the code to find the first match it finds and get out of the loop. The search should re-new when they change the active cell.

  17. #17
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    I want to find the first match and get out of the loop. When I change active cell it should renew the search!

  18. #18
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    So you do not need the loop
    The code will be launched again when clicking the button

  19. #19
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    I changed it Application.Goto Reference:=Worksheets("Production List").Range(firstAdd)

    it still doesn't work.
    I removed the loop too, still doesn't work.

    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    I am basically trying to create a find functionality with the search button and active cell.

  21. #21
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    With next code
    if you select in sheet "Sched List" cell "B5"
    If you clic you are selecting in sheet "Production List" cell "D2"
    You can come back to sheet "Sched List" and make another run ..!
    Is it what you want ??
    Please Login or Register  to view this content.

  22. #22
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,319

    Re: Code to find value in other worksheet in same workbook match with active cell

    Application.GoTo will jump to the cell specified, not return a value. Is that what you want?

    Please explain the process that you want to implement, NOT what you think the code does (or you think it should do).

    It sounds as though you need a Worksheet Change Event handler and, possibly, Application.WorksheetFunction.VLookup to return one or more values.

    If your code DID work, it looks as though you would enter a value in a cell, press a button, and that would jump to a matching cell on another sheet.

  23. #23
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    This is exactly what I want :

    Enter a value in a cell, press a button, and that would jump to a matching cell on another sheet.
    But my code isnt doing that. It just stays on the same active cell in Sched List worksheet.

  24. #24
    Forum Contributor
    Join Date
    12-20-2019
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    116

    Re: Code to find value in other worksheet in same workbook match with active cell

    Quote Originally Posted by pci View Post
    with next code
    if you select in sheet "sched list" cell "b5"
    if you clic you are selecting in sheet "production list" cell "d2"
    you can come back to sheet "sched list" and make another run ..!
    Is it what you want ??
    Please Login or Register  to view this content.
    this worked beautifully

  25. #25
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    Houfff...good news
    Happy Christmas with Excel ...!

  26. #26
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,319

    Re: Code to find value in other worksheet in same workbook match with active cell

    This does what you want, I just don't really understand why you want to do it.

    Please Login or Register  to view this content.

  27. #27
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Code to find value in other worksheet in same workbook match with active cell

    Do you know that you could use the DoubleClick option instead of the button: See file attached
    With next code just double click on cells in column "B" in sheet "Sched List"
    Sheet "Sched List" 's code
    Please Login or Register  to view this content.
    In a module
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. [SOLVED] VBA to SUM values from the same cell in every worksheet in an active workbook
    By hans302 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-11-2017, 05:01 AM
  2. [SOLVED] Hyperlink a worksheet to the active cell in a list on another worksheet in same workbook
    By Robn02 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-01-2017, 11:45 PM
  3. [SOLVED] Need Macro to find the active cell value on entire worksheet
    By warriorpoet7176 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-19-2016, 03:31 PM
  4. Getting code to find the selected Active cell
    By JO505 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-19-2015, 03:12 PM
  5. [SOLVED] Code to detect previous active workbook instead of current active workbook
    By kosherboy in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-25-2014, 01:58 AM
  6. Replies: 20
    Last Post: 01-11-2014, 05:39 AM
  7. Replies: 2
    Last Post: 07-10-2006, 03:29 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