Can I use variables in the Sourcedata from a Dynamic Table?? HELPPPPP

sergiomimo

New Member
Joined
May 13, 2013
Messages
4
How can i do this code works right, I need to use a variable

Act = InputBox("Today", "Now", Thisday) 'here i need to write: 10513 (sheet name)
Range("AA2").Select

This works OK
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="'10513'!R1C23:R117C23").CreatePivotTable TableDestination:="'[Control LE.xls]10513'!R4C27", TableName:="Tabla dinámica3", DefaultVersion:=xlPivotTableVersion10

This dont...ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="' Act '!R1C23:R117C23").CreatePivotTable TableDestination:="'[Control LE.xls]& Act '!R4C27", TableName:="Tabla dinámica3", DefaultVersion:=xlPivotTableVersion10
 
Last edited:
You have a little mistake with using Act variable.
Please, change
SourceData:="' Act '!R1C23:R117C23").CreatePivotTable
To
SourceData:="'" & Act & "'!R1C23:R117C23").CreatePivotTable
Regards,
 
Upvote 0
I am sorry. I did not look at end of your code. It is like
Change
TableDestination:="'[Control LE.xls]& Act '!R4C27"
To
TableDestination:="'[Control LE.xls]" & Act & "'!R4C27"
 
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