+ Reply to Thread
Results 1 to 3 of 3

Create a new chart for every change of values in a combobox

  1. #1
    uriel78
    Guest

    Create a new chart for every change of values in a combobox

    I've got a bar chart that takes values from cells A1:B5

    In C1 and in D1 I've got two combobox (created with data validation method),
    each one allows me to choose 4 different parameters. By changing these
    values, the values in A1:B5 and the chart changes too. Now, for every
    change of data in C1 and/or D1 I copy & paste the chart to another sheet; in
    this situation I've got only ONE chart
    Is there a way to obtain a *new* chart every time I change parameter in C1
    and D1, so that I can avoid to do the copy & paste the single chart manually
    (that is too much time-expensive) and put the it into another sheet ?

    Thanks in advance



  2. #2
    Debra Dalgleish
    Guest

    Re: Create a new chart for every change of values in a combobox

    You could use an event procedure to do this. Add the following code to
    the sheet module, as described here:

    http://www.contextures.com/xlvba01.html#Worksheet

    '=================================
    Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = "$C$1" Or _
    Target.Address = "$D$1" Then
    Charts.Add
    With ActiveChart
    .ChartType = xlColumnClustered
    .SetSourceData Source:=Range("A1:B5")
    .Location Where:=xlLocationAsNewSheet
    End With
    Me.Activate
    End If

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

    uriel78 wrote:
    > I've got a bar chart that takes values from cells A1:B5
    >
    > In C1 and in D1 I've got two combobox (created with data validation method),
    > each one allows me to choose 4 different parameters. By changing these
    > values, the values in A1:B5 and the chart changes too. Now, for every
    > change of data in C1 and/or D1 I copy & paste the chart to another sheet; in
    > this situation I've got only ONE chart
    > Is there a way to obtain a *new* chart every time I change parameter in C1
    > and D1, so that I can avoid to do the copy & paste the single chart manually
    > (that is too much time-expensive) and put the it into another sheet ?
    >
    > Thanks in advance
    >
    >



    --
    Debra Dalgleish
    Excel FAQ, Tips & Book List
    http://www.contextures.com/tiptech.html


  3. #3
    uriel78
    Guest

    Re: Create a new chart for every change of values in a combobox

    Thank you very much, it runs !!!


    "Debra Dalgleish" <[email protected]> ha scritto nel messaggio
    news:[email protected]...
    > You could use an event procedure to do this. Add the following code to
    > the sheet module, as described here:
    >
    > http://www.contextures.com/xlvba01.html#Worksheet
    >
    > '=================================
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > If Target.Address = "$C$1" Or _
    > Target.Address = "$D$1" Then
    > Charts.Add
    > With ActiveChart
    > .ChartType = xlColumnClustered
    > .SetSourceData Source:=Range("A1:B5")
    > .Location Where:=xlLocationAsNewSheet
    > End With
    > Me.Activate
    > End If
    >
    > End Sub
    > '====================================




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1