+ Reply to Thread
Results 1 to 22 of 22

know location after search

  1. #1
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    know location after search

    Hey there,

    I have searched the whole internet (at least I feel like I did) and can't figure this out on my own. PLEASE help me!

    I have a macro that works well so far but I'm stuck at one point. My macro searches a set of data (partnumbers) in one worksheet for a number (cvalue) out of another worksheet. If it finds the number (fvalue) I want it to copy the related quantity, which it would find in the next column. My code for searching looks like this:

    Please Login or Register  to view this content.
    And I find what I need but how do I now address the location where the partnumber (fvalue) is found to move the cursor from there? Unfortunately the found cell is not the active cell as I was hoping.

    THX, Obgle
    Last edited by jeffreybrown; 09-17-2012 at 08:51 AM.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    Try this Offset 0 rows 1 Column. This will give the value in Column b where fvalue was found

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    Thanks for your help!
    Unfortunately this gives the contend of the cell where fvalue was found.

    AND I want to move the cursor from fvalues location. Is there any possibility to know its location. Something lice Address or so?
    That would help me so much!

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: know location after search

    Try

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    Im lost is this what you want?

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    Both of them give me errors. For me both of them look like what I want, the position of the cell where my number is found but I'm doing something wrong. My variables are Dim as Range, is that right together with this?

  7. #7
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    If you can post your code in question then it would help us help you. Otherwise were just throwing darts blindfolded into the wind

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    Better yet upload your workbook

  9. #9
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    Ok, here is my workbook. It is an endless loop right now because of my issues to find that location :-)
    Attached Files Attached Files

  10. #10
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    Ok im looking at it now. So what exactly are you trying to do? I Probably would take the code out of the Workbook_Open Event.

  11. #11
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    The first sheet contains raw data. There are serial numbers in colum A and the quantity of those IDs in column C.
    On the second sheet I want to work with those data and have some of the serial numbers in column A (differen order) and the matching quantity in column D.

    Now I want to write a mocro that would start on top of column A (sheet 2) takes the serial number and searches for it in column A of sheet 1. If it finds the number I want it to write the matching quantity out of column c (sheet 1) into column D (sheet 2). If it doesn't find the number in the list I want it to write 0. and then do the same thing with the next serial number until the list on sheet 2 is over.

    I guess it looks quite chaotic to you, but please be gentle since this is my first macro ever :-)

  12. #12
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    Try this... remove the code you have in the Workbook_Open and Insert this into a Standard Module

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    Oh my, yours looks so much better than mine and it took you just minutes, where I worked days, lol!
    Thank you so much, it works. Except one thing:
    I writes 7815 into sheet2 D3, that is right and then it writes 13 into sheet2 D4 and that is not correct. It is the quantity of the part number one below the right one.

    And would you do me huge favor and write some comments into the code what is happening where? I know that is asked a lot but I would love to understand and learn for the next time...

  14. #14
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    Ups, I just found out your code works perfectly! It was my mistake, sorry!

  15. #15
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    Thank you so much again! It works perfectly no matter what I do with the list of numbers, I can't believe you wrote that so quickly!
    I appreciate your help already but would be VERY thankful for some comments in the code to understand what I'm doing ;-)

  16. #16
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    no problem heres the code with some comments. What part of NC are you from?

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    THX!!! It was sooo frustrating the last days :-)

    Originally I'm from Germany but living in Asheville, NC for one year now. I visited Florida last January and loved it (especially the Keys), which area do you live

  18. #18
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    Asheville uh? Its really nice over there. I use to ride my motor cycle over that way going to Tenn/Blue Ridge Parkway. I use to live in Pinehurst/Southern Pines NC. I moved down to Florida about 3 years ago. About an hour from Orlando, in Lake Wales.

  19. #19
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    Also have a brother living in Germany now. He was in the US Military, married a german girl and stayed over there..

  20. #20
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    Oh yes! This is the best location I know to ride a motorbike!

    By the way, how do I mark a thread as SOLVED? Can't find the button...

  21. #21
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: know location after search

    Click Thread Tools above your first post, select "Mark your thread as Solved"

  22. #22
    Registered User
    Join Date
    09-12-2012
    Location
    NC, USA
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: know location after search

    Aha, worked!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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