macro to Copy/Paste Cells based on value in a column

sheiono

New Member
Joined
Apr 25, 2011
Messages
5
Doing a favour for a friend and I am stuck...there is usually something I can find online to help me but I have looked for several hours and come up with zip...

In the macro below I would like to copy and paste rows (columns A though H only) from one worksheet ("Tracker")to the same columns on another ("Carpenter"), not the entire row. What I have is great for copy/pasting the entire row...

Am I furnishing enough information? I would appreciate any help out there!

Sub UpdateCarpenter()
Set i = Sheets("Tracker")
Set e = Sheets("Carpenter")

Dim d
Dim j
d = 3
j = 4

Do Until IsEmpty(i.Range("B" & j))

If i.Range("B" & j) = "Carpenter" Then
d = d + 1
e.Rows(d).Value = i.Rows(j).Value


End If
j = j + 1
Loop
End Sub

 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
try this

Code:
e.Range(Cells(d, "A"), Cells(d, "E")).Copy Destination:=i.Range(Cells(j, "A"), Cells(j, "E"))
in place of
e.Rows(d).Value = i.Rows(j).Value
 
Upvote 0
try this

Code:
e.Range(Cells(d, "A"), Cells(d, "E")).Copy Destination:=i.Range(Cells(j, "A"), Cells(j, "E"))
in place of
e.Rows(d).Value = i.Rows(j).Value
Thanks very much for taking the time to help, I tried that code and got the 'ol "400" error message. Not sure if you are comfortable with my sending you the file, but I would appreciate any other ideas you may have.
 
Upvote 0
ok so I changed it some to this

Code:
Sub UpdateCarpenter()
i = "Tracker"
e = "Carpenter"
Dim d
Dim j
d = 3
j = 4
Do Until IsEmpty(Sheets(i).Range("B" & j))
If Sheets(i).Range("B" & j) = "Carpenter" Then
d = d + 1
Sheets(i).Range("A" & j & ":E" & j).Copy Destination:=Sheets(e).Cells(d, "A")

End If
j = j + 1
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,134
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top