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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,575
Messages
5,832,576
Members
430,142
Latest member
ivonsurf123

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
Top