Copy data

lafrenie

Board Regular
Joined
May 30, 2007
Messages
60
I have a table with data in column A and B. In column C1 I have a formula that multiplies A1 by B1. I want the code that will allow me to copy this formula in column C for as long as there is data in column A. How should I do this ?
 

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
Try

Code:
Sub Cpy()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("C1").AutoFill Destination:=Range("C1:C" & LR)
End Sub
 
Upvote 0
After I copy the formula, I want to create a pivot table selecting data from column A to D until this last row of data in column A. I have tried the below but it is not working. Can you help ?




Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("d2").AutoFill Destination:=Range("d2:d" & LR)
Selection.NumberFormat = "#,##0_);[Red](#,##0)"
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
".csv data(1)!R1C1" & LR).CreatePivotTable TableDestination:="", _
TableName:="Tableau croisé dynamique1", DefaultVersion:= _
xlPivotTableVersion10
 
Upvote 0

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

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