VBA Code - Copying data from a range to next range

Vishaal

Well-known Member
Joined
Mar 16, 2019
Messages
533
Office Version
  1. 2010
  2. 2007
Platform
  1. Windows
  2. Web
Hi All,

Why the below code is not copying data to till last row

VBA Code:
Sub copytilllast()
LR = Cells(Rows.Count, 1).End(xlUp)(2).Row

    Range("N2").FormulaR1C1 = "Max"
    Range("N3").FormulaR1C1 = "Min"
    Range("O2").FormulaR1C1 = "=MAX(RC[-9]:R[4]C[-9])"
    Range("O3").FormulaR1C1 = "=MIN(R[-1]C[-8]:R[3]C[-8])"
    Range("P2:P3").FormulaR1C1 = "=ROUNDUP(RC[-1],0)"
    Range("Q2:Q3").FormulaR1C1 = "=RC[-1]+0.2"
    Range("N2:Q7").Copy Range("N2:Q" & LR)

End Sub

its only creating the data but not copying, pls check and solve
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Seems like this would be better. HTH. Dave
Code:
Sub copytilllast()
LR = Cells(Rows.Count, 1).End(xlUp).Row

    Range("N2").FormulaR1C1 = "Max"
    Range("N3").FormulaR1C1 = "Min"
    Range("O2").FormulaR1C1 = "=MAX(RC[-9]:R[4]C[-9])"
    Range("O3").FormulaR1C1 = "=MIN(R[-1]C[-8]:R[3]C[-8])"
    Range("P2:P3").FormulaR1C1 = "=ROUNDUP(RC[-1],0)"
    Range("Q2:Q3").FormulaR1C1 = "=RC[-1]+0.2"
    Range("N2:Q7").Copy Range("N2:Q" & LR + 1)

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,215,506
Messages
6,125,193
Members
449,213
Latest member
Kirbito

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