Results 1 to 5 of 5

Declare text to find in 2 workbooks

Threaded View

  1. #1
    Registered User
    Join Date
    05-28-2015
    Location
    Houston, TX
    MS-Off Ver
    2010
    Posts
    7

    Declare text to find in 2 workbooks

    Hello all,

    I have two workbooks. "Copy" is where I am organizing all of my data. "2014 Metric Summary Report" is a system output... and it's a mess. My goal is to have the macro find the asset (Listed in column A in both workbooks, but not the same order) and copy data from one workbook to the next for each asset.

    The debugger stops me at: Txt = Workbooks("WB1").Sheets("33300.20.5392877").Cell(i, 1).Value saying 'Subscript out of range.' Here is where I need the macro to somehow take the text in the cell and find that text in the second workbook.

    Sub Macro2()
    
        Dim i As Long
        Dim Txt$, MyPath$, WB1$, WB2$
        
        Application.ScreenUpdating = False
        
        MyPath = "C:\"
        WB1 = "Copy.xlsm"
        WB2 = "2014 Metric Summary Report.xlsm"
        Workbooks.Open Filename:=MyPath & WB2
        
        For i = 3 To 31
            Txt = Workbooks("WB1").Sheets("33300.20.5392877").Cell(i, 1).Value
            Workbooks("WB2").Range("A11:A30").Find(Txt, searchorder:=xlByColumns).Activate
            ActiveCell.Offset(0, 6).Copy
            Workbooks("WB1").Sheets("Live").Cell(i, 20).Paste
            Application.CutCopyMode = False
        Next i
            
    
    End Sub
    Any thoughts? Thanks for your time!

    P.S. Also, how could I qualify the code so that if the text is not found, it just goes onto the next i?
    Last edited by imaginekat; 08-05-2015 at 10:41 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. loop through workbooks to find term, find not working
    By bsapaka in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2015, 06:16 PM
  2. Replies: 9
    Last Post: 12-21-2014, 06:29 PM
  3. Find Text String across Multiple Workbooks
    By craigos in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-30-2013, 05:18 AM
  4. I can't declare a paragraph as non-script text
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2012, 10:22 PM
  5. Can't declare FinalRow
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2011, 02:02 AM
  6. Why declare variables
    By tryer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2009, 12:03 PM
  7. Declare Multiple Variables for any Open Workbooks
    By Bravurian17 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-14-2009, 11:11 PM

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