Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to macro simple graphs


Hi all, I wanted to thank the Excel community for your earlier efforts
by showing y'all how to macro a graph and save yourselves a number of
of steps.

To put this code into your excel sheet:
1. Start recording a macro. I recommend using control-a for the
hotkey. Stop recording,go into the macro code (tools-macro-macro),
and copy and paste the below code in place of what excel made.
2. In the code below, change "forecastv12" to the name of your current
excel file.

What this code does:
1. Select a range of cells with numbers in them, i.e. cell a1 through
cell a10,
2. Hit the hotkey (again, I recommend ctrl-a as it is easy to do
repeatedly).
3. You will see a simple line graph with a best-fit line complete with
equation.
4. This can be repeated as many times as you want.

If you want to customize this to your own taste and don't know how, try
putting your question here. Maybe someone will help!

Sub MakeNewGraph()
'
' MakeNewGraph Macro
' Macro recorded 8/4/2005 by ...
' Keyboard Shortcut: Ctrl+a
'
Dim sActiveSheet As String
sActiveSheet = Workbooks("Forecastv12.xls").ActiveSheet.Name
' Dim sActiveCol As String
' sActiveCol = ActiveCell.Name

Charts.Add
'Charts.Add.Name = "Column" + sActiveColumn
ActiveChart.Location Whe=xlLocationAsObject, Name:=sActiveSheet
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Trendlines.Add(Typ e:=xlLinear,
Forward:=0, _
Backward:=0, DisplayEquation:=True,
DisplayRSquared:=True).Select
ActiveChart.SeriesCollection(1).Trendlines(1).Data Label.Select
Selection.Left = 142
Selection.Top = 1


End Sub


--
mikerr
------------------------------------------------------------------------
mikerr's Profile: http://www.excelforum.com/member.php...o&userid=25830
View this thread: http://www.excelforum.com/showthread...hreadid=467236

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
Changing Simple lines and Graphics into Graphs with data Ish Excel Discussion (Misc queries) 2 December 20th 08 03:32 PM
Updating graphs in Excel using a macro Angela R Excel Discussion (Misc queries) 2 July 3rd 07 02:19 PM
macro for graphs BNT1 via OfficeKB.com Charts and Charting in Excel 9 February 1st 07 01:42 AM
macro to make line graphs WSIB#1 Charts and Charting in Excel 4 February 18th 05 01:42 PM
Linking graphs with macro Hasan Afzal Excel Programming 1 September 29th 04 02:05 AM


All times are GMT +1. The time now is 07:28 AM.

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"