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!
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
Re: How to transfer info from one sheet to another using a macro
Moved to the Office Development forum.
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
Re: How to transfer info from one sheet to another using a macro
Quote:
Originally Posted by
westconn1
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.
Re: How to transfer info from one sheet to another using a macro
Quote:
Run-time error 438" keeps popping up.
on which line?
Re: How to transfer info from one sheet to another using a macro
Quote:
Originally Posted by
westconn1
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
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")