#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Charts

I am writing a macro that calculates certain values in rows. Now I want to
make the macro automatically construct a predefined chart displaying the
information in the rows. Help!! Please!!
--
I am very thankful for any fast assistance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Charts

Hi Samantha,

Try turning on the macro recorder while you create the chart manually. The
resultant code may be edited to enable more general application.

If you experience problems with such editing, post back with the problematic
code.


---
Regards,
Norman


"SamanthaK" wrote in message
...
I am writing a macro that calculates certain values in rows. Now I want to
make the macro automatically construct a predefined chart displaying the
information in the rows. Help!! Please!!
--
I am very thankful for any fast assistance!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Charts

Thank you. However, the cells that I want to calculate are not the same every
time. It works like this: I copy information into the Excel-spreadsheet from
another program. The information is somewhat different every time although
certain types of info is required. I then search the headings in order to
identity the column that contains the desired data for a certain calculation.
E.g. I have market value (for a futures-contract) in one column and the date
in another column. The date in a certain row corresponds to the market value
in the same row. However the infor may be pasted into Excel at different
places every time so that row1 does not necessearlity imply a heading nor
does coulmn1 not imply e.g. date. I have managed to find the headings and
calculate the length the column. Now I want to make a predfined chart based
on the values. The problem is that the start and end of the coulmn as well as
the coulmn itself is variable. (sorry for the long text :-)) Can you help me
one this one please!!!.
--
I am very thankful for any fast assistance!


"Norman Jones" skrev:

Hi Samantha,

Try turning on the macro recorder while you create the chart manually. The
resultant code may be edited to enable more general application.

If you experience problems with such editing, post back with the problematic
code.


---
Regards,
Norman


"SamanthaK" wrote in message
...
I am writing a macro that calculates certain values in rows. Now I want to
make the macro automatically construct a predefined chart displaying the
information in the rows. Help!! Please!!
--
I am very thankful for any fast assistance!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Charts

Hi Samantha,

Try something like:

'=============
Public Sub Tester004()
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim FirstCell As Range
Dim LastCell As Range
Dim myChart As Object
Const myHeader As String = "Market Value" '<<===== CHANGE

Set WB = Workbooks("YourBook.xls") '<<===== CHANGE
Set SH = WB.Sheets("Sheet3") '<<===== CHANGE

Set FirstCell = SH.Cells.Find(What:=myHeader, After:=SH.Range("A1"))
Set LastCell = SH.Cells(Rows.Count, FirstCell.Column).End(xlUp)
Set rng = SH.Range(FirstCell, LastCell).Offset(0, -1).Resize(, 2)

Call GraphIt(SH, rng)

End Sub
'<<=============


'=============
Public Sub GraphIt(SH As Worksheet, rng As Range)
Dim CHObj As ChartObject

Set CHObj = SH.ChartObjects.Add(Left:=200, Top:=100, _
Width:=300, Height:=200) '<<=== CHANGE

With CHObj.Chart
.ChartType = xlLineMarkers
.SetSourceData Source:=rng, PlotBy _
:=xlColumns
.SeriesCollection(1).Name = "=""Values""" '<<=== CHANGE
.HasTitle = True
.ChartTitle.Characters.Text = "Market Data" '<<=== CHANGE

With .Axes(xlCategory, xlPrimary)
.HasTitle = True
.AxisTitle.Characters.Text = "Date" '<<=== CHANGE
End With

With .Axes(xlValue, xlPrimary)
.HasTitle = True
.AxisTitle.Characters.Text = "Value" '<<=== CHANGE
End With
End With

End Sub
'<<=============

--
---
Regards,
Norman



"SamanthaK" wrote in message
...
Thank you. However, the cells that I want to calculate are not the same
every
time. It works like this: I copy information into the Excel-spreadsheet
from
another program. The information is somewhat different every time although
certain types of info is required. I then search the headings in order to
identity the column that contains the desired data for a certain
calculation.
E.g. I have market value (for a futures-contract) in one column and the
date
in another column. The date in a certain row corresponds to the market
value
in the same row. However the infor may be pasted into Excel at different
places every time so that row1 does not necessearlity imply a heading nor
does coulmn1 not imply e.g. date. I have managed to find the headings and
calculate the length the column. Now I want to make a predfined chart
based
on the values. The problem is that the start and end of the coulmn as well
as
the coulmn itself is variable. (sorry for the long text :-)) Can you help
me
one this one please!!!.
--
I am very thankful for any fast assistance!


"Norman Jones" skrev:

Hi Samantha,

Try turning on the macro recorder while you create the chart manually.
The
resultant code may be edited to enable more general application.

If you experience problems with such editing, post back with the
problematic
code.


---
Regards,
Norman


"SamanthaK" wrote in message
...
I am writing a macro that calculates certain values in rows. Now I want
to
make the macro automatically construct a predefined chart displaying
the
information in the rows. Help!! Please!!
--
I am very thankful for any fast assistance!






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
charts toolbar / charts disappeared Pro Charts and Charting in Excel 0 December 18th 09 01:31 AM
link excel charts to web pages and update charts automatically Signguy Charts and Charting in Excel 1 April 22nd 08 08:29 PM
Charts - How to have multiple charts share a legend. Sean Charts and Charting in Excel 2 November 20th 07 04:49 AM
interactive charts for stacked bar charts [email protected] Charts and Charting in Excel 4 December 28th 06 09:58 PM
Matching the colors Column Charts and Pie Charts RohanSewgobind Charts and Charting in Excel 3 April 21st 06 09:35 PM


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