Results 1 to 4 of 4

Thread: Searching Excel with VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    2

    Post Searching Excel with VB

    Hi

    Was wondering if one of you guys/girls with better knowladge of using visual basic in Excel would be able to help me.

    What i would like to do is be able to search an excell workbook for an account number then copy all the information in that Row and place it into another workbook.

    I presume i would need to use an input box?with a Vlookup? would that be able to search a workbook?. The number that i would be looking for would be in the first colume on everysheet of the workbook. Its basically like the find function. just trying to make the whole process as automated as possible

    My Visual basic is limited and i have not programmed for a few years.

    Thanks in advance

  2. #2
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: Searching Excel with VB

    There is a find function.

    VB Code:
    1. set mycell = Range("A1:A65000").find("cobblers")
    2.  if not (mycell is nothing) then
    3.    msgbox "The row you are looking for is " & mycell.row
    4.  end if

    HTH

    zaza

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    2

    Re: Searching Excel with VB

    Thanks for the response...

    that code looks great.. im i right in saying that it will tell me the row number of the number i typed in??

    Im looking for something that will copy the whole row for the number i type in and put it on a different workbook.. if that makes any sense?

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Searching Excel with VB

    You should be able to replace the msgbox line with something like this:

    ThisWorkBook.Rows(mycell.row).Copy Workbooks("name of other workbook").Rows(1)

    Where 1 is the row of the other workbook to paste into.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width