LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically updating chart to include new column with VBA

I am trying to automatically update a chart using VBA whenever user
clicks on the worksheet.

Excel 2003 SP2 executes a SQL stored procedure and gets data from SQL
Server backend - about some project categories on a monthly basis. And
hence the each month a new column is added to the dataset for all
categories (rows). The previous months are not deleted, they are needed
as well. But the chart only shows the columns that were specified when
the chart was created and user has to manually right click and change
the "data range" in "Source Data" dialog box to include the new column.


After some research on google I found a formula that works:

=OFFSET(Call_Category_Monthly!$A$1,0,0,
COUNTA(Call_Category_Monthly!$A:$A),
COUNTA(Call_Category_Monthly!$1:$1))


but when I put in the formula in the data range text box on the "Source
Data" window, it changes to the actual column and row values:
=Call_Category_Monthly!$A$1:$K$7

I want to include some VBA code to update the chart and include the
newly added column automatically.

I recorded a macro while changing the data range, but that also gets
recorded as the actual values not what I enter (which is the OFFSET
function):

ActiveChart.SetSourceData
Source:=Sheets("Call_Category_Monthly").Range("A1: K7"), PlotBy:=xlRows

I do not know how to change the Range("A1:K7") to OFFSET / COUNTA
function. I tried a couple of times, but it failed.

I am a SQL Server DBA/Developer and new to Excel and VBA.

Any help will be greatly appreciated.

 
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
automatically updating chart rayteach Excel Worksheet Functions 4 May 30th 09 04:34 PM
Automatically updating chart titles antw Charts and Charting in Excel 1 January 23rd 09 08:11 PM
Chart Automatically Updating Amber Charts and Charting in Excel 1 June 2nd 07 01:46 PM
Updating a chart automatically jeffsumm Charts and Charting in Excel 4 December 28th 05 08:01 PM
updating a chart series automatically KyWilde Excel Programming 1 April 28th 05 02:13 PM


All times are GMT +1. The time now is 08:30 AM.

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

About Us

"It's about Microsoft Excel"