Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default macro for graphing - should be very easy...

hello,

i am trying to set up a keyboard shortcut where i can select some
cells, hit the shortcut and a graph would be build based on the
selected data. so far i can do that but i can only graph data from the
recorded range when i start the macro B4:J4 - i want to be able to
graph from any dataset i select...

Sub graph()
' Keyboard Shortcut: Ctrl+Shift+G
'
Range("B4:J4").Select
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B4:J4")
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
End Sub

thanks,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default macro for graphing - should be very easy...

Try something like this:

Sub graph()
' Keyboard Shortcut: Ctrl+Shift+G
'
ws = ActiveSheet.Name
sl = Selection.Address
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets(ws).Range(sl)
ActiveChart.Location Whe=xlLocationAsObject, Name:=ws
End Sub

HTH,
Paul


wrote in message
ups.com...
hello,

i am trying to set up a keyboard shortcut where i can select some
cells, hit the shortcut and a graph would be build based on the
selected data. so far i can do that but i can only graph data from the
recorded range when i start the macro B4:J4 - i want to be able to
graph from any dataset i select...

Sub graph()
' Keyboard Shortcut: Ctrl+Shift+G
'
Range("B4:J4").Select
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("B4:J4")
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
End Sub

thanks,



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
graphing using macro misschanda via OfficeKB.com Charts and Charting in Excel 2 September 7th 07 04:04 PM
Macro for graphing jrussl Charts and Charting in Excel 1 June 15th 06 02:24 AM
Macro for Graphing Current Sheet? Losse Excel Programming 6 July 5th 05 01:37 PM
Template for graphing algebra inequalities and easy to shade the . firetrk Charts and Charting in Excel 1 March 17th 05 04:57 PM
Macro for Graphing Data Newdlj Excel Programming 3 December 3rd 03 04:17 PM


All times are GMT +1. The time now is 05:20 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"