Reading filters fields in a pivot using vba
Hi
I am able to store the Row Fields, Value Fields, Column Fields of a pivot. But if a filters are applied to a pivot.
like Pivot.PivotFields, Pivot.RowFields, etc
How can we read the what is the field applied for the filter fields?
Thanks
Sreeram
Madhukar
Hi,
Please try the sample code, it'll read the filter field which you select:
Sub Test()
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Set pt = Sheets("Scores").PivotTables(1)
For Each pf In pt.PivotFields
If pf.Orientation = xlPageField Then
Debug.Print pf.Name
For Each pi In pf.PivotItems
If pi.Visible = True Then
Debug.Print pi.Value
End If
Next
End If
Next pf
End Sub
PS:
This is the forum to discuss questions and feedback for Microsoft Excel, if you have any further question about Excel developer, please post the question to the MSDN forum for Excel
http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs.
Similar Messages
-
Importing Structure field values in Excel using VBA and SAP RFC
I am calling a RFC MEASUREM_DOCUM_RFC_SINGLE_001 from Excel VBA. The export parameters of the RFC has a parameter MEASUREMENT_DOCUMENT and structure COMPLETE_DOCUMENT. I am able to get back parameter value in excel from RFC using
ActiveCell = Funct.imports("MEASUREMENT_DOCUMENT")
Now I want to get the value of one of the fields say POINT of the structure COMPLETE_DOCUMENT in Excel. The following code doesnt work
ActiveCell = Funct.imports("COMPLETE_DOCUMENT-POINT")
It gives an error.
Even I have tried to using code for tables
dim tab as object
set tab = funct.tabels("COMPLETE_DOCUMENT")
but it did'nt work.
Can any one help me how to access the field value of a structure?
regards
RavindraI am calling a RFC MEASUREM_DOCUM_RFC_SINGLE_001 from Excel VBA. The export parameters of the RFC has a parameter MEASUREMENT_DOCUMENT and structure COMPLETE_DOCUMENT. I am able to get back parameter value in excel from RFC using
ActiveCell = Funct.imports("MEASUREMENT_DOCUMENT")
Now I want to get the value of one of the fields say POINT of the structure COMPLETE_DOCUMENT in Excel. The following code doesnt work
ActiveCell = Funct.imports("COMPLETE_DOCUMENT-POINT")
It gives an error.
Even I have tried to using code for tables
dim tab as object
set tab = funct.tabels("COMPLETE_DOCUMENT")
but it did'nt work.
Can any one help me how to access the field value of a structure?
regards
Ravindra -
Reader X in Access 2007 form using VBA - GetPageNum
I have inserted the ActiveX control for the reader into a form in Access 2007. How do I determine which page of the PDF is currently being displayed? I understand that the method "GetPageNum" is for AcroExch.AVPageView, how do I get to the AV page view?
Thank you in advance!
JanetI think you need either the SDK or Scripting forums
http://forums.adobe.com/community/acrobat -
Prepopulating Interactive Form with XML Data using VBA
I have an excel spreadsheet with data on it. I need to click on a button that will cause an Interactive PDF form to open and be populated with data from the spreadsheet. To do this I want to use an XML data file. I know how to create the file, but how do I cause the PDF to open in Adobe Reader with the XML data file using VBA? The link needs to be a soft link, in that the name of the XML file could change.
Many thanks for answers.strXFDFFile = "c:\temp\" & strFileName & "tmp.xfdf"
'Open the PDF file
appPDFInit = True
Status "Processing " & strFileName
DoEvents
' Create PDF File, if any
If strXFDFFile <> "" Then
Dim fldValue As String
Open strXFDFFile For Output As #1
Print #1, "<?xml version=""1.0"" encoding=""UTF-8""?>"
Print #1, "<xfdf xmlns=""http://ns.adobe.com/xfdf/"" xml:space=""preserve"">"
Print #1, "<f href=""" & strFilePath & strFileName & """/>"
Print #1, "<fields>"
For Each fdField In rsData.Fields
If IsNull(fdField.Value) Then
fldValue = ""
Else
fldValue = fdField.Value
fldValue = XMLit(fldValue)
End If
If InStr(1, fdField.Name, "ID") > 0 Then
fldValue = Format(fldValue, "##########")
End If
If InStr(1, fdField.Name, "ZIP") > 0 Then
fldValue = Format(fldValue, "#####")
End If
If InStr(1, fdField.Name, "Rate") > 0 Then
fldValue = Format(fldValue, "#0.00#")
End If
' Write #1, fdField.Name,
Print #1, "<field name=""" & fdField.Name & """>"
Print #1, "<value>" & fldValue & "</value>"
Print #1, "</field>"
Next
Print #1, "</fields>"
Print #1, "</xfdf>"
Close #1
End If
Dim x As Long
For x = 1 To 1000000: Next x
LaunchPDF.LaunchFile strXFDFFile, 0, 2
Make sure you reference the Adobe Acrobat Browser Control Library under Tools | References
It will merge to Adobe Reader. Note that I have made the strXFDFFile variable unique by including the name of the PDF file. This assures that you can merge to more than one PDF at a time (this is taken from a loop for multiple PDF files). Note that the XFDF file must include the path and the PDF file name in order to open the correct PDF for merging.
I don't have time to explain the code, but if you have any questions let me know.
Daniel H. Smith
Smith Enterpises LLC -
Can no longer select text in email template or read only field with mouse using IE or Firefox?
Hi Guys,
I can no longer select text in email template or read only field using my mouse in IE or Firefox anymore. We are using CRM 2011 rollup 18 applied with IE 11 and the latest version of Firefox. We only applied roll up 18 in Feb when this issue began.
Thanks
Dave
David KellyWhen you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.
(1) Bypass Firefox's Cache
Use Ctrl+Shift+r to reload the page fresh from the server.
(You also can clear Firefox's cache completely using:
orange Firefox button ''or'' Tools menu > Options > Advanced
On the Network mini-tab > Cached Web Content : "Clear Now")
(2) Remove the site's cookies (save any pending work first) using either of these. While viewing a page on the site:
* right-click and choose View Page Info > Security > "View Cookies"
* Alt+t (open the classic Tools menu) > Page Info > Security > "View Cookies"
Then try reloading the page. Does that help?
These features rely on JavaScript, and it sounds as though you have scripting enabled if you get (the wrong) color changes. Some add-ons might alter the way scripts operate, so a standard diagnostic to bypass interference by extensions (and some custom settings) is to try Firefox's Safe Mode.
First, I recommend backing up your Firefox settings in case something goes wrong. See [[Backing up your information]]. (You can copy your entire Firefox profile folder somewhere outside of the Mozilla folder.)
Next, restart Firefox in Firefox's Safe Mode ([[Safe Mode]]) using
Help > Restart with Add-ons Disabled
In the dialog, click "Start in Safe Mode."
If those features work correctly, this points to one of your extensions or custom settings as the problem.
To also disable plugins, you can use this page:
orange Firefox button ''or'' classic Tools menu > Add-ons > Plugins category
Any change? -
Hi,
I am trying to add a calculated field in my power pivot table to show the percentage on the basis of 2 columns, please let me know why this is not appearing and how can i fix it.
Any other way if i can add a calculated field in the pivot table will be very helpful.
Thanks
AmanThanks KR for the response,
Yes I loaded multiple tables in the data model and using PoewrPivot ,
i have a rating column, in that i have 0,1,2,3,4,5 rating numbers and we call it "Total expected occurrence",
a single person can get same rating multiple times, if a person is getting >=4 rating no. we call it "Occurrence >= 4". now i have to find out the total
count of "Occurrence >=4" for a particular person from "Total expected occurrence" column,
once will get the net "Occurrence >=4" for everyone, it should divide
"Occurrence >=4"/ "Total expected occurrence" to take out the percentage of rating 4 for a particular person
Best Wishes,
Aman verma -
Export Project Tasks to Excel using VBA by Custom Field
Question referring to the link:
http://social.technet.microsoft.com/Forums/projectserver/en-US/9c46458c-893f-41ba-bd46-bdb59c533f4a/export-project-tasks-to-excel-using-vba-by-custom-field?forum=project2010custprog
Help needed. I have inserted my question at this address for Andrew or anybody else to reply. Hope to hear from you.
Regards,
ChuckThank you Andrew for getting back to me and I have found somewhere on the net the following macro that would do the job for the version 2007. Here is a copy for those that may need it.
Option Explicit
Sub CreateMenus()
Dim cbrMain As CommandBar
Dim ctlMain As CommandBarControl
Dim ctlOLExport1 As CommandBarControl
Dim ctlOLExport2 As CommandBarControl
Dim ctlOLExport3 As CommandBarControl
Set cbrMain = Application.CommandBars.ActiveMenuBar
Set ctlMain = cbrMain.Controls.Add(Type:=msoControlPopup, Temporary:=True)
ctlMain.Caption = "Export to Outlook"
Set ctlOLExport1 = ctlMain.CommandBar.Controls.Add(Type:=msoControlButton)
With ctlOLExport1
.Caption = "Selection to Outlook tasks"
.OnAction = "Macro """ & "Export_Selection_To_OL_Tasks"""
End With
Set ctlOLExport2 = ctlMain.CommandBar.Controls.Add(Type:=msoControlButton)
With ctlOLExport2
.Caption = "Selection to Outlook appointments"
.OnAction = "Macro """ & "Export_Selection_To_OL_Appointments"""
End With
Set ctlOLExport3 = ctlMain.CommandBar.Controls.Add(Type:=msoControlButton)
With ctlOLExport3
.Caption = "Selection to Outlook notes"
.OnAction = "Macro """ & "Export_Selection_To_OL_Notes"""
End With
End Sub
Cheers!
Chuck -
Upload a value in read-only field using Webservices or Workflow
Can you please let me know if is feasible to upload a value into a read-only field using webservices or workflow
If so, can you please provide an example?
ThanksUsing WS, you cant update the field value, if it is set as "Read-Only" @ the object - Field definition level, but you can update that using WS if it is set as "Read-Only" @ the layout level. Same applicable to Workflows too
-- Venky CRMIT -
How to Insert Sharepoint 2013 Person or Group Field using VBA
Hello,
How to Insert Sharepoint 2013 Person or Group Field using VBA , I tried set the field with ID / ID;Name / Name
but all failed, Please advice
Function SetSP_Field(F_Yer As Single, F_WekNo As Single, F_ProjectNum As String, strField As Variant, strFieldValue As Variant) As String
' test code
Dim rst As Recordset
Dim strSQL As String
Dim SP_RecSet As ADODB.Recordset
Set SP_RecSet = New ADODB.Recordset
SetSP_Field = False
strSQL = "Status Report"
On Error Resume Next
Call SP_Connect(2)
strSQL = "select " & SP_List & ".* From " & SP_List _
& " Where [Year] = " & CInt(F_Yer) _
& " and [WeekNo] = " & CInt(F_WekNo) _
& " and [Compass_Code] = '" & F_ProjectNum & "' ; " _
' & " Set " & strField & " = " & strFieldValue
'Debug.Print strSQL
'Debug.Print SP_CN
SP_RecSet.Open strSQL, SP_CN, adOpenStatic, adLockOptimistic
If SP_RecSet.RecordCount = 0 Then
Debug.Print "Record for project: " & F_ProjectNum & " not found"
LogFile.WriteLine ("Record " & strID & " not found")
End If
If Not SP_RecSet.EOF Then
'SP_RecSet.Edit
SP_RecSet.Fields(strField) = strFieldValue
SP_RecSet.Update
If Err.Number <> 0 Then
MsgBox ("SP Update Error: " & Err.Description)
GoTo Exit_Fun
End If
SetSP_Field = True
End If
Exit_Fun:
SP_RecSet.Close
Set SP_RecSet = Nothing
End FunctionHi Tim,
Let’s verify the followings:
Whether this issue occurred for other lists in the same site.
Whether this issue occurred for all users who don’t have full control.
Whether this issue occurred on other sites.
When you created the people & group column, which show field did you used? Please try to use a different show field for the people & group column, compare the result.
In addition, please check if the link is useful:
http://www.learningsharepoint.com/2013/08/21/empty-value-in-people-picker-after-saving-the-list-form-in-sharepoint/
Best Regards,
Wendy
Wendy Li
TechNet Community Support -
Hi there,
I'm trying to access few fields for example Description, History,Repro Steps etc. ,but I get error as
Error: This item must be open to read this field.
How do i fix this?
Thanks,
AnuWorkItem.Open() ?
There is no open() method for workitem
is there any other solution?
Thanks
Anusha -
I've got some tables in Access which I export to Excel using VBA. Once exported, I'd like to add some pivot tables, special formatting and formulas into the workbook. Any idea how to do this? Here are some specific tasks after the export:
1. Insert a pivot table into a 2nd sheet. The pivot table will have a filter field.
2. Format the column widths in that pivot table and add some conditional cell colors
Anybody know how to code this? I assume I'll need to export from access then open the excel file and use excel object model from within access?
ajwYou can certainly import Access tables into Excel:
http://www.erlandsendata.no/english/index.php?d=envbadacimportado
http://www.erlandsendata.no/english/index.php?d=envbadacimportdao
http://www.erlandsendata.no/english/index.php?d=envbadacrs2ws
See this too.
http://www.accessmvp.com/KDSnell/EXCEL_Export.htm#WriteRstFile
http://www.accessmvp.com/KDSnell/EXCEL_Export.htm#ExpCopyFromRst
That's just several similar, but slightly different, ways to do the same thing. Once your data is in Excel, turn on the Macro Recorder and run through the steps you need to do, to get the Pivot Table the way you want it, then turn off the Macro Recorder
and view the code.
You will almost certainly need to make some modifications to the recorded code, because everything will be fixed (hard-coded). Post back with additional questions, or start a new thread, to see how to make the next part(s) work. Just get comfortable
with the first part(s) for now.
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it. -
How can I export multiple PDF fillable forms into a spreadsheet (Excel) using VBA?
Hi guys,
I never used VBA with with Adobe Acrobat. I would like a tip to start doing that. What I would like to do know is:
1 - I have multiple PDF Forms that are filled.
2 - I want all the data from those forms to be exported to Excel via VBA code.
3 - Adobe Acrobat already have an option to do that manually (Forms > Merge Data Files Into Spreadsheet) and it works perfectly.
4 - I would like to access that feature using VBA, then generate a spreadsheet.
Any tips? How can I start?
Thanks!A good place to start is Karl Heinz Kremer's blog, where he has a few examples:
http://khkonsulting.com/2010/09/reading-pdf-form-fields-with-vba/ -
How to Unpivot, Crosstab, or Pivot using Oracle 9i with PL/SQL?
How to Unpivot, Crosstab, or Pivot using Oracle 9i with PL/SQL?
Here is a fictional sample layout of the data I have from My_Source_Query:
Customer | VIN | Year | Make | Odometer | ... followed by 350 more columns/fields
123 | 321XYZ | 2012 | Honda | 1900 |
123 | 432ABC | 2012 | Toyota | 2300 |
456 | 999PDQ | 2000 | Ford | 45586 |
876 | 888QWE | 2010 | Mercedes | 38332 |
... followed by up to 25 more rows of data from this query.
The exact number of records returned by My_Source_Query is unknown ahead of time, but should be less than 25 even under extreme situations.
Here is how I would like the data to be:
Column1 |Column2 |Column3 |Column4 |Column5 |
Customer | 123 | 123 | 456 | 876 |
VIN | 321XYZ | 432ABC | 999PDQ | 888QWE |
Year | 2012 | 2012 | 2000 | 2010 |
Make | Honda | Toyota | Ford | Mercedes|
Odometer | 1900 | 2300 | 45586 | 38332 |
... followed by 350 more rows with the names of the columns/fields from the My_Source_Query.
From reading and trying many, many, many of the posting on this topic I understand that the unknown number or rows in My_Source_Query can be a problem and have considered working with one row at a time until each row has been converted to a column.
If possible I'd like to find a way of doing this conversion from rows to columns using a query instead of scripts if that is possible. I am a novice at this so any help is welcome.
This is a repost. I originally posted this question to the wrong forum. Sorry about that.The permission level that I have in the Oracle environment is 'read only'. This is also be the permission level of the users of the query I am trying to build.
As requested, here is the 'create' SQL to build a simple table that has the type of data I am working with.
My real select query will have more than 350 columns and the rows returned will be 25 rows of less, but for now I am prototyping with just seven columns that have the different data types noted in my sample data.
NOTE: This SQL has been written and tested in MS Access since I do not have permission to create and populate a table in the Oracle environment and ODBC connections are not allowed.
CREATE TABLE tbl_MyDataSource
(Customer char(50),
VIN char(50),
Year char(50),
Make char(50),
Odometer long,
InvDate date,
Amount currency)
Here is the 'insert into' to populate the tbl_MyDataSource table with four sample records.
INSERT INTO tbl_MyDataSource ( Customer, VIN, [Year], Make, Odometer, InvDate, Amount )
SELECT "123", "321XYZ", "2012", "Honda", "1900", "2/15/2012", "987";
INSERT INTO tbl_MyDataSource ( Customer, VIN, [Year], Make, Odometer, InvDate, Amount )
VALUES ("123", "432ABC", "2012", "Toyota", "2300", "1/10/2012", "6546");
INSERT INTO tbl_MyDataSource ( Customer, VIN, [Year], Make, Odometer, InvDate, Amount )
VALUES ("456", "999PDQ", "2000", "Ford", "45586", "4/25/2002", "456");
INSERT INTO tbl_MyDataSource ( Customer, VIN, [Year], Make, Odometer, InvDate, Amount )
VALUES ("876", "888QWE", "2010", "Mercedes", "38332", "10/13/2010", "15973");
Which should produce a table containing these columns with these values:
tbl_MyDataSource:
Customer VIN Year Make Odometer InvDate Amount
123 | 321XYZ | 2012 | Honda | 1900 | 2/15/2012 | 987.00
123 | 432ABC | 2012 | Toyota | 2300 | 1/10/2012 | 6,546.00
456 | 999PDQ | 2000 | Ford | 45586 | 4/25/2002 | 456.00
876 | 888QWE | 2010 | Mercedes | 38332 | 10/13/2010 | 15,973.00
The desired result is to use Oracle 9i to convert the columns into rows using sql without using any scripts if possible.
qsel_MyResults:
Column1 Column2 Column3 Column4 Column5
Customer | 123 | 123 | 456 | 876
VIN | 321XYZ | 432ABC | 999PDQ | 888QWE
Year | 2012 | 2012 | 2000 | 2010
Make | Honda | Toyota | Ford | Mercedes
Odometer | 1900 | 2300 | 45586 | 38332
InvDate | 2/15/2012 | 1/10/2012 | 4/25/2002 | 10/13/2010
Amount | 987.00 | 6,546.00 | 456.00 | 15,973.00
The syntax in SQL is something I am not yet sure of.
You said:
>
"Don't use the same name or alias for two different things. if you have a table called t, then don't use t as an alais for an in-line view. Pick a different name, like ordered_t, instead.">
but I'm not clear on which part of the SQL you are suggesting I change. The code I posted is something I pieced together from some of the other postings and is not something I full understand the syntax of.
Here is my latest (failed) attempt at this.
select *
from (select * from tbl_MyDataSource) t;
with data as
(select rownum rnum, t.* from (select * from t order by c1) ordered_t), -- changed 't' to 'ordered_t'
rows_to_have as
(select level rr from dual connect by level <= 7 -- number of columns in T
select rnum,
max(decode(rr, 1, c1)),
max(decode(rr, 2, c2)),
max(decode(rr, 3, c3)),
max(decode(rr, 4, c3)),
max(decode(rr, 5, c3)),
max(decode(rr, 6, c3)),
max(decode(rr, 7, c3)),
from data, rows_to_have
group by rnumIn the above code the "select * from tbl_MyDataSource" is a place holder for my select query which runs without error and has these exact number of fields and data types as order shown in the tbl_MyDataSource above.
This code produces the error 'ORA-00936: missing expression'. The error appears to be starting with the 'with data as' line if I am reading my PL/Sql window correctly. Everything above that row runs without error.
Thank you for your great patients and for sharing your considerable depth of knowledge. Any help is gratefully welcomed. -
Plot a scatter two-y axis using VBA?
I am working for a company on the oil and gas field. We are collecting data for pressure and load in every job we do. I am in charge on making a code to plot these sets of data using VBA in Excel. Does anyone know how to write a code for plotting in a
different sheet a two-y axis (pressure and load) vs time graph using VBA in Excel?Hi,
This is the forum to discuss questions and feedback for Microsoft Excel, this issue is more relate to Excel DEV, please post the question to the MSDN forum for Excel
http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in
Office programs. -
I wish to use VBA and Excel to programmatically open numbered Dreamweaver HTML (CS5) and find and replace text in the code view of these files, save and close them.
I have 5000 associations between Find: x0001 and Replace: y0001 in an Excel sheet.
I have the VBA written but do not know how to open, close and save the code view of the ####.html files. Please ... and thank you...
[email protected]This is actually the code view of file ####.html that I wish to find and replace programmatically where #### is a four digit number cataloguing each painting.... In 1995 I thought this was clever... maybe not so clever now :>)) Thank you for whatever you can do Rob!
!####.jpg!
h2. "Name####"
Oils on acrylic foundation commercial canvas - . xx X xx (inches) Started
Back of the Painting In Progress </p> </body> </html>
Warmest regards,
Phil the Forecaster, http://philtheforecaster.blogspot.ca/ and http://phils-market.blogspot.ca/
Maybe you are looking for
-
Error when modifying tabular form
Hi In Apex 3, I created a tabular form based on the query below: select user_id /* PK */, name, dob from users It works perfectly well; I am able to update the name and dob fields. Then I changed the query to: select user_id /* PK */, name, null dob
-
System gets Slow after 10.6.5 update
So, I just updated it using standalone combo installer and straight away notice that to repair the disc permitions now takes 3 mins, before it took only 1min. even if there is nothing to repair. and futher more my whole system gets very slow after a
-
I have created stored procedure with %rowtype as IN OUT parameter.I want to
i have created stored procedure with %rowtype as IN OUT parameter.I want to call it in java program
-
OdiRef.getTable("ID") error in JKM
Looking at ML Doc ID 1285904.1 , regarding work arounds for long table names with ODI CDC. Suggestion to use flexfields sounds a good idea, but the code provided on that ML note does not seem to work as a generic substitution method. I've changed the
-
Am using the following: JMSServerMBean to get a list of JMS Destinations and trying to call the removeDestination I get the following on the weblogic log: <Nov 26, 2001 5:27:01 PM EST> <Info> <JMS> <JMSServer "AutexJMSServer", des ion BECKER will be