Silly Problem with Variable (2nd attempt)

P

pikapika13

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

Acell = ActiveCell


However, the following code does not work:
ActiveSheet.PivotTables("PivotTable10").PivotFields("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?
 
V

vezerid

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
 
K

Kevin B

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.
 
Top