Macro to copy Data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,605
Office Version
  1. 2021
Platform
  1. Windows
I need code the will copy a formula into cell F9 and then copy this formula into all cells in column F where there is data in the last row in col E

I have listed my code below, which is not copying the data into F10 onwards

Sub Copy_Data ()

im LR As Long
LR = Cells(Rows.Count, "E").End(xlUp).Row
With Range("F9")
.FormulaR1C1 = "=RC[-2]&"" ""&RC[-1]"
.Range("f9").Copy
.Range("F10:F" & LR).Paste
.Application.CutCopyMode = False

End With
End Sub


Your assistance will be most appreciated

Regards

Howard
 
Hello Howard

You don't need to use copy since you are using that type of R1C1 formula, the following should achieve the same:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Copy_Data()<br><br><SPAN style="color:#00007F">Dim</SPAN> LR <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br><br>LR = Cells(Rows.Count, "E").End(xlUp).Row<br><br>Range("F9:F" & LR).FormulaR1C1 = "=RC[-2]&"" ""&RC[-1]"<br><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>


Can you confirm that you have data in column E below row 9?
 
Upvote 0
This should do the same
Code:
Sub Copy_Data ()
 
Range("F9", Range("f" & Rows.Count).End(xlUp)).Formula = "=d9&"" ""&e9"
 
End Sub
 
Upvote 0
Hi Jon & Jindon

Thanks for the help

Regards

Howard
 
Upvote 0

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