ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Silly Problem with Variable (2nd attempt) (https://www.excelbanter.com/excel-discussion-misc-queries/80816-silly-problem-variable-2nd-attempt.html)

pikapika13

Silly Problem with Variable (2nd attempt)
 

I'm new to VBA.
I'm passing a value to "Acell":

Acell = ActiveCell


However, the following code does not work:
ActiveSheet.PivotTables("PivotTable10").PivotField s("utcid")
.PivotItems(Acell).Visible = False

But when I manually put in "37" (in quotes), it works. Please help.

BTW, is there a way to follow your code step by step? similar to the
formula auditing tool in Excel?


--
pikapika13
------------------------------------------------------------------------
pikapika13's Profile: http://www.excelforum.com/member.php...o&userid=10892
View this thread: http://www.excelforum.com/showthread...hreadid=528593


vezerid

Silly Problem with Variable (2nd attempt)
 
Since ActiveCell returns an object, assignment must be made with Set:

Set Acell = ActiveCell

It would be a good idea to first declare Acell

Dim Acell as Object '-----or
Dim Acell as Range

Also, PivotItems probably needs Acell.Value (what is the 37?)

HTH
Kostis Vezerides


Kevin B

Silly Problem with Variable (2nd attempt)
 
To pass the value to ACell
Acell = ActiveCell.value

To step through a procedure, press the F8 key to execute line by line. You
can also set breakpoints by moving to the line you want execution to stop on
and pressing F9.

Then when you run your code, either by running the macro from the menu or
pressing F5 in a module, it will execute to the breakpoint, and you can F8
your way through the procedure from there. At any time you can press F5 to
run the procedure to completion.
--
Kevin Backmann


"pikapika13" wrote:


I'm new to VBA.
I'm passing a value to "Acell":

Acell = ActiveCell


However, the following code does not work:
ActiveSheet.PivotTables("PivotTable10").PivotField s("utcid")
.PivotItems(Acell).Visible = False

But when I manually put in "37" (in quotes), it works. Please help.

BTW, is there a way to follow your code step by step? similar to the
formula auditing tool in Excel?


--
pikapika13
------------------------------------------------------------------------
pikapika13's Profile: http://www.excelforum.com/member.php...o&userid=10892
View this thread: http://www.excelforum.com/showthread...hreadid=528593




All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com