Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 864455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:28:53+00:00 2026-05-15T09:28:53+00:00

A little help needed, I have a Macro automatically creating pivot tables and charts,

  • 0

A little help needed, I have a Macro automatically creating pivot tables and charts, this is all working fine but I am getting (blank) in my pivot table becuase my range is all the way to 65536.
How do I automatically get the lastrow / column in my source data so I dont get any blanks. The data is changing constantly so this needs to be automatic

Here is the source data, I am looking to get the R65536C37 to be automatically generated based on the lastcolumn of the “raw” sheet

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    "raw!R1C1:R65536C37").CreatePivotTable _
    TableDestination:="Frontpage!R7C1", TableName:="PivotTable2", _
    DefaultVersion:=xlPivotTableVersion10

I have tried;

LastRow = ActiveSheet.UsedRange.Rows.Count
SourceData:= "raw!R1C1:" & LastRow & C37"

Pivot Macro

    Sheets("Frontpage").Select
Range("A7").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    "raw!R1C1:R65536C37").CreatePivotTable _
    TableDestination:="Frontpage!R7C1", TableName:="PivotTable2", _
    DefaultVersion:=xlPivotTableVersion10
Sheets("Frontpage").Select
Cells(7, 1).Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("Frontpage!$A$7:$H$22")
ActiveChart.ChartType = xlColumnClustered
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Priority")
    .Orientation = xlRowField
    .Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
    "PivotTable2").PivotFields("Case ID"), "Count of Case ID", xlCount
ActiveChart.Parent.Name = "IncidentsbyPriority"
ActiveChart.ChartTitle.Text = "Incidents by Priority"
Dim RngToCover As Range
Dim ChtOb As ChartObject
Set RngToCover = ActiveSheet.Range("D7:L16")
Set ChtOb = ActiveSheet.ChartObjects("IncidentsbyPriority")
ChtOb.Height = RngToCover.Height ' resize
ChtOb.Width = RngToCover.Width ' resize
ChtOb.Top = RngToCover.Top ' reposition
ChtOb.Left = RngToCover.Left ' reposition

Any help would be greatly appreciated. I need to repeat this in four other pivots so as to avoid getting (blank) in my tables and charts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T09:28:53+00:00Added an answer on May 15, 2026 at 9:28 am

    I usually use a Named Dynamic Range.
    For example create a Named Range called RawData with a formula :
    =OFFSET(Raw!$A$1,0,0,COUNTA(Raw!$A:$A),COUNTA(Raw!$1:$1))

    This assumes that there are no blanks contained within the data in column 1 or row 1 (blanks/empty beyond the end of data is not a problem).

    If there are blanks within your data then you need to use a different function: you can download a set of functions (fxlCountFuncs.zip) for this kind of counting from
    http://www.decisionmodels.com/downloads.htm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.