Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for Graphing Current Sheet?


I would like to have my macro graph the sheet I am on without having t
type in different names as I change different files. The SourceDat
looks like this right now:

ActiveChart.SetSourceData Source:=Sheets("sName").Range("A1:B400")
PlotBy _
:=xlColumns

Is there any way I can get sName to be the name of the curren
worksheet I am viewing

--
Loss
-----------------------------------------------------------------------
Losse's Profile: http://www.excelforum.com/member.php...fo&userid=2481
View this thread: http://www.excelforum.com/showthread.php?threadid=38368

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for Graphing Current Sheet?


That only gives me an error. It tells me "Object doesn't support thi
property or method." I belive there needs to be an "_" after the PlotB
as well

--
Loss
-----------------------------------------------------------------------
Losse's Profile: http://www.excelforum.com/member.php...fo&userid=2481
View this thread: http://www.excelforum.com/showthread.php?threadid=38368

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for Graphing Current Sheet?


Is what I'm asking impossible

--
Loss
-----------------------------------------------------------------------
Losse's Profile: http://www.excelforum.com/member.php...fo&userid=2481
View this thread: http://www.excelforum.com/showthread.php?threadid=38368

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Macro for Graphing Current Sheet?

Did the line you posted actually work? I was assuming it did....

You could always try

dim sName as string

sName = activesheet.name

ActiveChart.SetSourceData _
Source:=Sheets(sName).Range("A1:B400"), _
PlotBy :=xlColumns

Tim

"Losse" wrote in
message ...

That only gives me an error. It tells me "Object doesn't support
this
property or method." I belive there needs to be an "_" after the
PlotBy
as well.


--
Losse
------------------------------------------------------------------------
Losse's Profile:
http://www.excelforum.com/member.php...o&userid=24813
View this thread:
http://www.excelforum.com/showthread...hreadid=383681



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default Macro for Graphing Current Sheet?

Obviously the newsreader inserted a line feed between "PlotBy" and ":=".
Does the code work when it's all on a single line? If your first posted
code worked, so should Tim's altered code.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Losse wrote:

That only gives me an error. It tells me "Object doesn't support this
property or method." I belive there needs to be an "_" after the PlotBy
as well.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro for Graphing Current Sheet?

Today i have solved the same problem you have this code is in one
Workbook and creates a chart in the active workbook the values are in
column "C".

Sub Grafico()
Dim wb As Workbook
Dim ws As Worksheet
Dim cht As Excel.Chart


Set wb = ActiveWorkbook
'

Set ws = wb.Sheets(1)

'nombra la hoja actual
ws.Name = "TOC"

'Define el rango de trabajo RngC
wb.Names.Add Name:="RngC", RefersToR1C1:= _
"=OFFSET(TOC!R1C3,0,0,COUNTA(TOC!C3))"

Application.ScreenUpdating = False
Set cht = ws.ChartObjects.Add(50, 50, 400, 300).Chart



With cht
.ChartType = xlXYScatterSmoothNoMarkers



..SetSourceData Source:=ws.Range("TOC!RngC"), PlotBy:=xlColumns
.Location Whe=xlLocationAsObject, Name:="TOC"
.HasTitle = True
.ChartTitle.Characters.Text = "TOC en "
With .Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With .Axes(xlValue)
.HasTitle = True
.AxisTitle.Characters.Text = "ppb"
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
.HasLegend = False
With .PlotArea
With .Border
.ColorIndex = 16
.Weight = xlThin
.LineStyle = xlContinuous
End With
With .Interior
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
End With
End With
Application.ScreenUpdating = True


'Quita las unidades del eje X
ActiveChart.Axes(xlCategory).Select
ActiveChart.ChartArea.Select
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = False
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
End Sub

Jon Peltier wrote:
Obviously the newsreader inserted a line feed between "PlotBy" and ":=".
Does the code work when it's all on a single line? If your first posted
code worked, so should Tim's altered code.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Losse wrote:

That only gives me an error. It tells me "Object doesn't support this
property or method." I belive there needs to be an "_" after the PlotBy
as well.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for Graphing Current Sheet?


Thank you, Tim. That worked perfectly for me. It did not work, however,
until I changed it into the format you posted.


--
Losse
------------------------------------------------------------------------
Losse's Profile: http://www.excelforum.com/member.php...o&userid=24813
View this thread: http://www.excelforum.com/showthread...hreadid=383681

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
Display current sheet name being processed in macro Ann New Users to Excel 5 April 17th 07 01:18 PM
How can I Run a query from VB macro with out affect current data in the same sheet? oafdl Excel Discussion (Misc queries) 0 May 29th 06 09:42 PM
Graphing past months (totals) and current month (weekly total) in Davin Charts and Charting in Excel 1 July 27th 05 05:01 PM
Return to Current Sheet in On (sheet activate) event macro Paul Moles Excel Programming 1 March 27th 05 03:16 PM
Use current sheet name in Macro Bernie Deitrick Excel Programming 0 January 21st 04 04:48 PM


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