Paste Values with VBA Code

L

Legacy 428781

Guest
I want to add a line of code to my VBA to copy only the values of column B with no formatting.

Part of my code looks like this:

<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">If Worksheets("one").Cells(i, 4).Value = "TRUE" Then
Worksheets
("one").Cells(i, 2).Copy
erow
= Worksheets("two").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets
("one").Paste Destination:=Worksheets("two").Cells(erow + 1, 1)</code>

A simple paste values method works if a range is specified like this;

Range("A1:A3").Copy
Range("B1:B3").pastespecial xlPasteValues

However what I actually want is to add the paste values into the existing code which is specifying a specific column.

How do I modify my code so only values are copied from column B and pasted into another worksheet?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Remove the line that copies and then replace this line...

Code:
Worksheets("one").Paste Destination:=Worksheets("two").Cells(erow +1,1)

With this:

Code:
Worksheets("two").Cells(erow + 1, 1) = Worksheets("one").Cells(i, 2).Value
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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