Results 1 to 8 of 8

Thread: How to transfer info from one sheet to another using a macro

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    Exclamation How to transfer info from one sheet to another using a macro

    This is my first post, and I sure hope I can find some help!

    Basically, I have two sheets: 1) "Labor Report" (LR) and 2) "Budget Hours" (BH). If LR has a value in column "A" that matches a value from column "A" in BH, then I would like the corresponding data from the row in BH to be transferred to the row in LR. There are 9 columns worth of data that are coming from "R," "U," "X," "AA," "AD," "AG," "AJ," "AM", and "P." The cells from the duplicate rows need to be copied into the same columns for the row in which the original resides in LR.

    I hope that makes sense.

    Please let me know if you need a more concrete example!

  2. #2

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    Re: How to transfer info from one sheet to another using a macro

    Also, for what it's worth, I'm working off of Excel 2007

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: How to transfer info from one sheet to another using a macro

    Moved to the Office Development forum.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to transfer info from one sheet to another using a macro

    something like
    Code:
    for each cel in sheets("LR")
        set fnd = sheets("BH").range("a:a").find(cel)
        if not fnd is nothing then
           fnd.offset(, 18).value = cel.offset(, 18)   ' column p, 
           '  do same for other cells to copy
       end if
    next
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    Re: How to transfer info from one sheet to another using a macro

    Quote Originally Posted by westconn1 View Post
    something like
    Code:
    for each cel in sheets("LR")
        set fnd = sheets("BH").range("a:a").find(cel)
        if not fnd is nothing then
           fnd.offset(, 18).value = cel.offset(, 18)   ' column p, 
           '  do same for other cells to copy
       end if
    next
    Westconn,

    Thank you for your reply! The coding you provided me seems simple enough, but for some reason every time I try running it, a "Run-time error 438" keeps popping up. I have attempted to implement a series of modifications but to no avail.

    Would you happen to have any suggestions?

    Thanks again.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to transfer info from one sheet to another using a macro

    Run-time error 438" keeps popping up.
    on which line?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2013
    Posts
    4

    Re: How to transfer info from one sheet to another using a macro

    Quote Originally Posted by westconn1 View Post
    on which line?
    When I go to debug, it directs me to line 4 and says, "Object doesn't support this property or method "

    Sub ExtractData()
    'get info from budget hours to labor report
    '
    For Each cel In Sheets("LR")
    Set fnd = Sheets("BH").Range("a:a").Find(cel)
    If Not fnd Is Nothing Then
    fnd.Offset(, 18).Value = cel.Offset(, 18) ' column p,
    ' do same for other cells to copy
    End If
    Next

    End Sub

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to transfer info from one sheet to another using a macro

    ok, assuming this is the line you are referring to, try
    Code:
    for each cel in sheets("LR").range ("a:a")
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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