Charting Macro Help

can someone help? trying to figure out a way to create a macro that takes data from column A and column B and creates a chart.

Any ideas on the code to do this?

Thanks!
eastsidemarketAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steven HarrisPresidentCommented:
Here is one example from Peltier Technical Services, Inc..  It will prompt you for the range to put the chart and a range to select for the data.

Option Explicit

Sub CreateChart()
  Dim objChart As ChartObject
  Dim myChtRange As Range
  Dim myDataRange As Range
  With ActiveSheet
    ' What range should chart cover
    Set myChtRange = Application.InputBox( _
        prompt:="Select a range where the chart should appear.", _
        title:="Select Chart Position", Type:=8)
    ' What range contains data for chart
    Set myDataRange = Application.InputBox( _
        prompt:="Select a range containing the chart data.", _
        title:="Select Chart Data", Type:=8)
    ' Cover chart range with chart
    Set objChart = .ChartObjects.Add( _
        Left:=myChtRange.Left, Top:=myChtRange.Top, _
        Width:=myChtRange.Width, Height:=myChtRange.Height)
    ' Put all the right stuff in the chart
    With objChart.Chart
        .ChartArea.AutoScaleFont = False
        .ChartType = xlXYScatterLines
        .SetSourceData Source:=myDataRange
        .HasTitle = True
        .ChartTitle.Characters.text = "My Title"
        .ChartTitle.Font.Bold = True
        .ChartTitle.Font.Size = 12
        With .Axes(xlCategory, xlPrimary)
            .HasTitle = True
            With .AxisTitle
                .Characters.text = "My X Axis"
                .Font.Size = 10
                .Font.Bold = True
            End With
        End With
        With .Axes(xlValue, xlPrimary)
            .HasTitle = True
            With .AxisTitle
                .Characters.text = "My Y Axis"
                .Font.Size = 10
                .Font.Bold = True
            End With
        End With
    End With
  End With
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eastsidemarketAuthor Commented:
useful thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.