|
-
May 9th, 2013, 05:38 PM
#1
Thread Starter
New Member
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!
-
May 9th, 2013, 05:40 PM
#2
Thread Starter
New Member
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
-
May 9th, 2013, 07:25 PM
#3
Re: How to transfer info from one sheet to another using a macro
Moved to the Office Development forum.
-
May 10th, 2013, 05:16 AM
#4
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
-
May 10th, 2013, 10:50 AM
#5
Thread Starter
New Member
Re: How to transfer info from one sheet to another using a macro
 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.
-
May 10th, 2013, 04:31 PM
#6
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
-
May 10th, 2013, 05:16 PM
#7
Thread Starter
New Member
Re: How to transfer info from one sheet to another using a macro
 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
-
May 11th, 2013, 05:19 AM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|