Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jan 2004
    Posts
    196
    Thanks
    1
    Thanked 0 Times in 0 Posts

    copy from workbook to workbook (2003)

    I have 2 workbooks open. The 1st is one sheet filled out daily, consisting of a list of wells I collect information on. The 2nd is a summary workbook, each well has its own sheet. I have started a macro to copy the information from the 1st to the 2nd.
    The 1st sheet looks like the attachment...


    I am looking for a way to change tabs on the 2nd sheet as i move down the 1st sheet or vise versa.


    thanks,
    jackal
    Attached Images Attached Images

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: copy from workbook to workbook (2003)

    Are the sheets in the second workbook named after the entries in the leftmost column in the screenshot?

    If so, and assuming for simplicity that it's column A, you could use something like this:

    Dim r As Long
    Dim m As Long
    Dim wshSrc As Worksheet
    Dim wshTrg As Worksheet
    Set wshSrc = ActiveSheet
    m = wshSrc.Range("A" & wshSrc.Rows.Count).End(xlUp).Row
    For r = 3 To m
    Set wshTrg = Workbooks("Otherworkbook").Worksheets(wshSrc.Range ("A" & r))
    ' Copy a value
    wshTrg.Range("B1") = wshSrc.Range("B" & r)
    ...
    Next r

  3. #3
    2 Star Lounger
    Join Date
    Jan 2004
    Posts
    196
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: copy from workbook to workbook (2003)

    Attached it my target file, where i have the macro. I am stuck as how to make what you have provided work. I will add another post with the source file.

    thanks,
    jackal
    Attached Files Attached Files

  4. #4
    2 Star Lounger
    Join Date
    Jan 2004
    Posts
    196
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: copy from workbook to workbook (2003)

    here is the source file.

    thanks,
    Jackal
    Attached Files Attached Files

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: copy from workbook to workbook (2003)

    See the macro in the attached text file. I have added comments to the code.
    Attached Files Attached Files

Posting Permissions

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