Matador_24
Board Regular
- Joined
- Dec 1, 2011
- Messages
- 205
Hello,
I am working on a code that extracts data from a pivot table.
When using this code, I get the value I want to obtain, basically I obtain the value of Account number 10003 for the period 3 of Year 2017 from a complex pivot table:
Now, the account number will change depending on data and thus, I need to replace the 10003 by a variable in the code. However, I have an error on the syntax when using the variable LngAccount:
Does anybody know how to use a variable with the above code??????
note that the result of the msgbox is xx10003xx, meaning that the value of LngAccount is 10003, I did it to test if the format was fine.
I have searched on line but I have not been able to find something similar,
Help please!
Thanks,
Luis
I am working on a code that extracts data from a pivot table.
When using this code, I get the value I want to obtain, basically I obtain the value of Account number 10003 for the period 3 of Year 2017 from a complex pivot table:
Code:
LngValue = ActiveSheet.PivotTables(1).GetPivotData("Amount", "Account Number", "10003", "Period Year", "2,016", "Period Month", "3")
Now, the account number will change depending on data and thus, I need to replace the 10003 by a variable in the code. However, I have an error on the syntax when using the variable LngAccount:
Code:
Dim LngValue As Long
Dim LngAccount As Long
LngAccount = 10003
MsgBox "xx" & LngAccount & "xx"
LngValue = ActiveSheet.PivotTables(1).GetPivotData("Amount", "Account Number", LngAccount, "Period Year", "2,016", "Period Month", "3")
Does anybody know how to use a variable with the above code??????
note that the result of the msgbox is xx10003xx, meaning that the value of LngAccount is 10003, I did it to test if the format was fine.
I have searched on line but I have not been able to find something similar,
Help please!
Thanks,
Luis