Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Data ranges for Graphs & pivot tables in macros

I am having trouble generating graphs and pivot tables
with a macro from the correct data. I used the relative
reference feature when recording the macro, but the visual
basic code is always relying on the specific range I used
when it actually creates the new item.

Example (Graph then pivot table):
Range("A2:C2").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Range("A1:C19").Select
Charts.Add

***
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.PivotCaches.Add
(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R4C1:R227C42").CreatePivotTable
TableDestination:="", TableName:= _
"PivotTemp_1"


This works fine this time, but the next time I run the
macro I'll have more data and this won't recognize
anything below the original data block boundaries.

Also, if anybody's looking for extra credit, I'd can't
figue out how to select a range that doesn't include a
summary row at the bottom. In this case, say that A1
contains a Header, A2:C2 contain column labels, A3:C19
contain data (which will expand several rows before the
next time I run the macro), and A20:C20 is a summary row.
I need to find a way to start at A2 and select A2:C19
using relative references.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic data ranges in pivot tables Grey Old Man[_2_] Excel Discussion (Misc queries) 3 May 19th 10 06:41 PM
Pivot Tables and Graphs (charts) learnlearn52 Charts and Charting in Excel 4 June 5th 09 06:37 PM
Pivot Tables with Multiple ranges Rick Excel Discussion (Misc queries) 0 August 17th 07 01:44 AM
excel graphs data labels in Pivot tables Rosa Campos Charts and Charting in Excel 0 May 9th 06 07:55 PM
Problem with times in pivot tables and graphs [email protected] Excel Discussion (Misc queries) 2 February 23rd 05 06:59 AM


All times are GMT +1. The time now is 12:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"