Assing variable row to pivot chart in macro

Purenergy

New Member
Joined
Jun 2, 2010
Messages
38
Good day all,

Would anyone know how I can make this work:

HTML:
Sub PREPARATION_TDC_II()
'
' PREPARATION_TDC Macro
'
'
    Dim i As Long
 
 
    Sheets("AFVAL NO GRPS").Select
 
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    i = Selection.Rows.Count
 
 
    Sheets.Add
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "AFVAL NO GRPS!R1C1:RiC34", Version:=xlPivotTableVersion10). _
        CreatePivotTable TableDestination:="Feuil28!R3C1", TableName:= _
        "Tableau croisé dynamique1", DefaultVersion:=xlPivotTableVersion10
    Sheets("Feuil28").Select
    Cells(3, 1).Select
End Sub

What I want to do is that the size of the source data range be adjusted to the data, no matter if it grows in rows as I will have every time more and more rows.

As you see, I used the variable i in the range of the pivot table but it does not work.

Thank you for your assistance.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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