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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,225,730
Messages
6,186,698
Members
453,369
Latest member
positivemind

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