VBA Macro, copy and paste between cells

PrstgWrldwde

New Member
Joined
Aug 13, 2015
Messages
6
I'm trying to copy a value and paste it using R1C1 function.
Most of my macro looks like this (which works):

Range("A2").Select
ActiveCell.FormulaR1C1 = "=IF(R[-1]C[-10]=""value"",R[1]C[1],"""")"

The above pattern is getting all of the values that I want into appropriate columns. Where I'm having trouble is with a particular string where I'm trying to copy/paste the cell value in one column for every instance that there is a cell with data in another column:

Range("F42").Select
Selection.Copy
Range("T2").Select
ActiveCell.FormulaR1C1 = "=IF(Range(RC[2]<>"",Selection.Paste)"

So in words: copy the value from cell F42, then paste in column T for every instance that there is an adjacent cell (RC[2]) that is not empty. I keep getting errors and have tried many different options.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I am thinking that the formula needs to only have formula language and not VBA code.

Try:
Code:
Range("T2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[2]<>"""",R[40]C[-14])"
 
Upvote 0
Thank you.

Is there another way I can solve the problem without formula language?

"If there is a value in a cell in another column, then paste this value in Column A"
 
Upvote 0

Forum statistics

Threads
1,223,108
Messages
6,170,140
Members
452,304
Latest member
Thelingly95

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