+ Reply to Thread
Results 1 to 10 of 10

Convert Range of a Pivot Table to R1C1 format

  1. #1
    Registered User
    Join Date
    04-01-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    7

    Convert Range of a Pivot Table to R1C1 format

    I'm trying to specify the range of a Pivot Table as the .RowSource of a Userform Listbox. It needs to be represented in R1C1 format. Can anyone tell me how to do that? (Note: the TableRange1 is the range of cells that I really want as input to the listbox)

    Here is the code I have so far. (The Pivot table is selected ok but the .RowSource doesn't work)

    Dim RngOfPvt As String

    Worksheets("Temp Pivots").PivotTables("PivotTable1").TableRange1.Select
    MsgBox Application.ConvertFormula(Worksheets("Temp Pivots").PivotTables("PivotTable1").SourceData, xlR1C1, xlA1)

    RngOfPvt = Application.ConvertFormula(Worksheets("Temp Pivots").PivotTables("PivotTable1").SourceData, xlR1C1, xlA1)

    UserForm1.ListBox1.RowSource = RngOfPvt
    UserForm1.Show

    Thanks for your help.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Convert Range of a Pivot Table to R1C1 format

    Please Login or Register  to view this content.
    not sure why your code used sourcedata or why you wanted r1c1 references?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    04-01-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Convert Range of a Pivot Table to R1C1 format

    Quote Originally Posted by JosephP View Post
    Please Login or Register  to view this content.
    not sure why your code used sourcedata or why you wanted r1c1 references?
    Thanks for the response Joseph. When I try your line of code I get the error "Permission denied". Any thoughts?

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Convert Range of a Pivot Table to R1C1 format

    clear the rowsource property of the listbox

  5. #5
    Registered User
    Join Date
    04-01-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Convert Range of a Pivot Table to R1C1 format

    Joseph,

    After I clear the rowsource property I get the error "Could not set the Value property. Invalid property value. Here is the line of code.

    UserForm1.ListBox1.List = Worksheets("Temp Pivots").PivotTables("PivotTable1").TableRange1.Value

    Thoughts?

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Convert Range of a Pivot Table to R1C1 format

    I can't see any problems in the code-can you post a workbook with the form and pivot table?

  7. #7
    Registered User
    Join Date
    04-01-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Convert Range of a Pivot Table to R1C1 format

    Ok. I got it to work. Apparently it was a problem with clearing the listbox using the .clear method.
    I commented out the clear and entered the line after it and it worked fine.

    Please Login or Register  to view this content.
    For the benefit of others, what this code does is put the TableRange1 (In my case headers and data) of the pivot table into the listbox.

    Thanks Joseph for your help.

    Gorilla

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Convert Range of a Pivot Table to R1C1 format

    for information to get the r1c1 address
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-01-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Convert Range of a Pivot Table to R1C1 format

    You are good!

    Thanks.

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Convert Range of a Pivot Table to R1C1 format

    I figured you might want to use the columnheads and you can only do that with a rowsource :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1