Dear Reader
My excel workbook consists of the following:-
Sheet1: Data for pivot table
Sheet2: Pivot Table
Sheet3: Options to be checked in the "Values" of the PivotTable Field List.
Is there a macro for automatically checking options in the pivottable field list from the values in Sheet3?
Thanks in advance. :)
Compare line 11 in your second block of code with lines 9 and 10 in your first block of codes.
Also, you have an infinite loop. I don't understand the loop you initiate on line 6. You never change its value so the loop is never going to exit.
Finally, I would avoid using the code to activate sheets. Just reference the sheets explicitly.
7 4599
Your question has been moved to the Access VBA forum as that's closer to the topic of the thread.
Yes there is. If you record a macro of you checking the option for the pivot table, you can then go in and edit the literal reference to your cell reference.
Dear Rabbit
Thank you for your post. I was able to record the following code:- - Dim UserName As String
-
Sheets("Sheet3").Activate
-
Range("A2").Select
-
-
Do Until (ActiveCell.Value = "")
-
UserName = ActiveCell.Value
-
-
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables("PivotTable1").PivotFields(UserName), "Count of " & UserName, xlCount
-
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of " & UserName).Caption = "Sum of " & UserName
-
.Function = xlSum
-
End With
-
Loop
-
End Sub
But, I am getting run-time error '1004' : Unable to get the PivotTables property of the Working Class. Any ideas?
Your active sheet is sheet3. I thought you said your pivot table was on sheet2? You would need to use sheet2, not your active sheet.
Now I am getting the error 'Invalid Qualifier' for the 'Sum of & UserName' in the 4th last line in the code which reads as follows:- -
Dim UserName As String
-
-
Sheets("Sheet3").Activate
-
Range("A2").Select
-
-
Do Until (ActiveCell.Value = "")
-
UserName = ActiveCell.Value
-
Sheets("Sheet2").Activate
-
-
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables("PivotTable1").PivotFields(UserName), "Count of " & UserName, xlCount
-
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Count of " & UserName).Caption = "Sum of" & UserName.Function = xlSum
-
End With
-
Loop
-
End Sub
-
Compare line 11 in your second block of code with lines 9 and 10 in your first block of codes.
Also, you have an infinite loop. I don't understand the loop you initiate on line 6. You never change its value so the loop is never going to exit.
Finally, I would avoid using the code to activate sheets. Just reference the sheets explicitly.
Thank you for your help. My problem is solved. :)
Glad you got it working.
I moved the thread again because we just opened up a new Excel forum.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ward B |
last post by:
Greetings all.
I'm getting the following error message...
Unknown column 'icaodesc' in 'field list'
when I try to update a table from a PHP form.
What 'field list' is it referring to? My...
|
by: Filo |
last post by:
Hello,
Design nice PivotTable or PivotChart (selecting fileds,captions,
colors, fonts, order of fieds etc.) sometimes takes more then 1 hour
and I hate when after this my boss (or I self) ask me...
|
by: Nospam |
last post by:
I installed a script that is suppose to accept paypal, however on trying to
test a payment, I get this error msg:
Error
Database access error
and I get this error msg emailed to me:
|
by: wcamp |
last post by:
I would like a "field list" to appear in report design.
Clicking the "filed list" icon nothing happens.
Have tried dozens of ways to get a "field list",
so far no luck! Have created over 5 ACCESS...
|
by: gerryblanco |
last post by:
Hi,
After creating all my tables, forms, and queries... I entered some sample data for testing... all was working... at the last minute I decided to add a text field in one of my tables. When I...
|
by: chunk1978 |
last post by:
hello.
so i have 2 select menus which add and remove options from a 3rd select menu... it seems, however, that it's not possible to use different select menus to toggle a 3rd, because when an...
|
by: G Jones |
last post by:
Let me start by saying I am a graphic designer who understand things very well, but by no means am I a programmer or developer. So here is my question....
I have put together a simple form that...
|
by: ebernedo |
last post by:
Hey guys,
I have two main questions
First off (pictures are kind of blurry)
I have this table
http://i197.photobucket.com/albums/aa109/ebernedo/DiscTable.jpg
And thats my database I use my...
|
by: tofusunday |
last post by:
I am pretty new to editing things in vba access. I have a report that didn't have a field that I needed in the field list, I modified the recordsource query, it is a sql pass through query:
SELECT...
|
by: kevinkwh |
last post by:
Hi,
I'm an intern student and my boss told me to do porting
from Linux c to Visual C++.When I built the coding, I found this error "unexpected in macro formal parameter list", here is the coding...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |