Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro in a worksheet template that draws data from other files? | New Users to Excel | |||
Invisible precedent lines. The system draws them but I can't see t | Excel Worksheet Functions | |||
Excel chart draws line outside Y axis | Charts and Charting in Excel | |||
Pool Draws (bracket) | Excel Worksheet Functions | |||
It would be great to have Round Robin Draws for 3-30 players | Excel Discussion (Misc queries) |