Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
I really need some help Please !!
Hi
I have asked a couple of times but it do not work like I wnat it to. Here is my question. I want to be able to in an Excel sheet to have a popup window that will allow me to choose a sheet and then to choose the two columns that I want to use to draw a chart. I also want the two columns to switch so that if I choose column N first and then column S in my chart N will be Y and S will be X. I can get it to work when I specifice the sheet and the columns but how can I choose ? Here is my macro where I have specified the sheet and columns Sub Chart() ' ' Chart Macro ' Macro recorded 07-02-2005 by f09593 ' ' Sheets("TR6_BP3_BP5_122_125_20050408_00").Select Range("N:N,S:S").Select Range("S2").Activate Charts.Add ActiveChart.ChartType = xlXYScatterSmoothNoMarkers ActiveChart.SetSourceData Source:=Sheets("TR6_BP3_BP5_122_125_20050408_00"). _ Range("N1:N9261,S1:S9261"), PlotBy:=xlColumns ActiveChart.SeriesCollection(1).XValues = _ "=TR6_BP3_BP5_122_125_20050408_00!R2C19:R9261C 19" ActiveChart.SeriesCollection(1).Values = _ "=TR6_BP3_BP5_122_125_20050408_00!R2C14:R9261C 14" ActiveChart.Location Whe=xlLocationAsNewSheet ActiveChart.ChartTitle.Select Selection.Characters.Text = "Capacity test 067L5640 #115" & Chr(10) & " TR6 BP3" Selection.AutoScaleFont = False With Selection.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 With ActiveChart.Axes(xlValue) .HasMajorGridlines = True .HasMinorGridlines = False End With ActiveChart.HasLegend = False ActiveChart.PlotArea.Select With Selection.Border .ColorIndex = 16 .Weight = xlThin .LineStyle = xlContinuous End With Selection.Interior.ColorIndex = xlNone ActiveChart.ChartArea.Select and so on.... I have also tried some of the answers here but it does not work because it stops right after I close the popup window. What am I doing wrong ? Here is what I have so far. This is my module: Option Explicit Public Rng1 As Range Public Rng2 As Range Sub Testme() UserForm2.Show MsgBox Rng1.Address 'Range from RefEdit MsgBox Rng2.Address 'Range from RefEdit Call PlotChart End Sub Sub PlotChart() Rng1.Select 'Range from RefEdit inserted in SetSourceData below Rng2.Select 'Range from RefEdit inserted in SetSourceData below Rng1 , Rng2.Activate Charts.Add ActiveChart.ChartType = xlXYScatterSmoothNoMarkers ActiveChart.SetSourceData Source:=Range(Rng2, 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 With ActiveChart.Axes(xlCategory) .HasMajorGridlines = True .HasMinorGridlines = False End With With ActiveChart.Axes(xlValue) .HasMajorGridlines = True .HasMinorGridlines = False End With ActiveChart.HasLegend = False ActiveChart.PlotArea.Select With Selection.Border .ColorIndex = 16 .Weight = xlThin .LineStyle = xlContinuous End With Selection.Interior.ColorIndex = xlNone ActiveChart.ChartArea.Select and so on... This is my userform: 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 Rng1 = 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 I have in the userform one conbobox and two refeditboxes. Please I need your help !! Susanne |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|