Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default It works .... but only 1 time

Hello,

From access I want to export a query to Excel (wit the help of som e VBA
code). I do this because I want to make a proper graph (among some other
things). Because the number of columns can change (so the number of series in
my chart) I want to use a piece of VBA code to expand my graph as needed.
This piece of VBA code looks if there is a column left, if yes I add it to
the graph as a new series.

I recorded a macro in Excel and got the following piece of VBA code for
adding the column to the graph:
================================================== ===
xlAppForm.Worksheets(WorksheetName ).Range(ActiveSheet.Cells(16, 14 + Sprong
*
T2), ActiveSheet.Cells(27, (14 + Sprong * T2))).Select
xlAppForm.Selection.Copy

xlAppForm.ActiveSheet.ChartObjects("Grafiek 2").Activate
xlAppForm.ActiveChart.ChartArea.Select

xlAppForm.ActiveChart.SeriesCollection.Paste Rowcol:=xlColumns,
SeriesLabels:=False, CategoryLabels:=False, Replace:=False, NewSeries:=True
xlAppForm.ActiveChart.SeriesCollection(T2 + 1).Name = xlAppQuery.Cells(T1, 2)
================================================== ===

The VBA code above works fine, but ....... it works only 1 time. The second
time (after I run the programm again) no series/columns are added to the
graph. Do i close access (where the VBA code is located) and start the
programm again, it works 1 time and not a second time.

Who can help me to make a piece of VBA code which works every time?

Thanks, JeroenM.

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
macro that works one time every day Spiros Excel Discussion (Misc queries) 2 September 19th 08 12:00 PM
Time for M$ to fix incompatibility with Office & Works Steve Garry Excel Discussion (Misc queries) 0 April 20th 06 09:10 PM
how do I create a hyperlink that works more than one time mcgrath Excel Discussion (Misc queries) 0 February 13th 06 03:41 PM
Works every second time hih Excel Programming 2 January 20th 06 06:06 PM
CopyPicture only works second time AllanS Excel Programming 2 September 20th 05 01:32 PM


All times are GMT +1. The time now is 03:33 PM.

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"