Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Macro that draws a chart

Hi

I have been trying to make a macro that make a popup window where I can
select a sheet and then I have to select two different columns for my chart.
I now have some of it working but itseems that it does not take the right
range. For example I want to have the N column as X and the S column as Y and
then in the chart I want to switch them so that S is X and N is Y.

This is what I have so far but I seem to be getting all the columns from N
to S.
Any help is appriciated.

This is my userform with 1 combobox and 2 refeditbox

Private Sub RefEdit1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Set Rng1 = Range(RefEdit1.Value)
End Sub
Private Sub RefEdit2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Set Rng2 = Range(RefEdit2.Value)
End Sub
Private Sub UserForm_Initialize()
Dim ws As Worksheet
For Each ws In Worksheets
ComboBox1.AddItem ws.Name
Next
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.ListIndex = -1 Then Exit Sub
Worksheets(ComboBox1.Value).Activate
End Sub

and this is some of my module

Option Explicit
Public Rng1 As Range
Public Rng2 As Range

Sub Testme()
UserForm1.Show
MsgBox Rng1.Address 'Range from RefEdit
MsgBox Rng2.Address 'Range from RefEdit
Call PlotChart
End Sub
Sub PlotChart()
Range(Rng1, Rng2).Select 'Range from RefEdit inserted in SetSourceData
below
Range(Rng1, Rng2).Activate
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=Rng1, PlotBy:=xlColumns
ActiveChart.SeriesCollection(1).XValues = Rng2
ActiveChart.SeriesCollection(1).Values = Rng1
ActiveChart.Location Whe=xlLocationAsNewSheet
ActiveChart.ChartTitle.Characters.Text = "Capacity test 067L5640 #115" &
Chr(10) & " TR6 BP3"
Selection.AutoScaleFont = False
With ActiveChart.ChartTitle.Characters(Start:=1, Length:=36).Font
.Name = "Arial"
.FontStyle = "fed"
.Size = 11.5
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
With ActiveChart
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Superheat
[°K]"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Capacity in
Tons refrigeration [R22]"
End With
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = True
.HasMinorGridlines = False
End With
and so on ....

Susanne


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 in a worksheet template that draws data from other files? sgdav New Users to Excel 1 February 18th 07 09:04 PM
Invisible precedent lines. The system draws them but I can't see t EJKorvette Excel Worksheet Functions 0 September 1st 06 07:20 PM
Excel chart draws line outside Y axis pc Charts and Charting in Excel 2 July 24th 06 01:36 AM
Pool Draws (bracket) auststan69 Excel Worksheet Functions 1 March 12th 06 06:21 AM
It would be great to have Round Robin Draws for 3-30 players Marinbiker Excel Discussion (Misc queries) 0 November 8th 05 03:56 PM


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