Results 1 to 4 of 4

Thread: Macro that finds data in another .xls file?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2012
    Posts
    1

    Macro that finds data in another .xls file?

    I'm quite new to VBA so bare with me...

    I'm looking for a macro that will find a piece of text (A1234) in another .xls file, call it "FILE2". I want the macro to check just the A column in "FILE2" and when "A1234" is found to copy the whole row to the file with the macro, "FILE1".

    Can someone help me get it working?

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

    Re: Macro that finds data in another .xls file?

    Welcome to VBForums

    Thread moved from the 'VB6' forum to the 'Office Development/VBA' forum (while VBA and VB6 have some similarities, they are not the same thing)

  3. #3
    New Member
    Join Date
    Aug 2012
    Posts
    3

    Re: Macro that finds data in another .xls file?

    Code:
    Sub WorkBookReference()
    
    Dim DestinationB, SourceB As String
    
    SourceB = "Book3"
    DestinationB = "Book2"
    
    Workbooks(Destination).Worksheets("Sheet1").Range("A1") = Workbooks("Source").Worksheets("Sheet1").Range("A2")
    
    End Sub
    I bolded the values you'd have to change

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Macro that finds data in another .xls file?

    Welcome to the forums Kaitsu

    You can use .FIND to find text in other workbook. See this link on how to use .Find

    TOPIC: .Find and .FindNext In Excel VBA
    LINK: http://siddharthrout.wordpress.com/2...-in-excel-vba/

    Once you get the row of the found value using aCell.Row then you can simply copy that row

    Give it a try and if you get stuck then simply post the code that you tried and the error that you are getting. We will then take it from there.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

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