+ Reply to Thread
Results 1 to 2 of 2

Create Chart from Macro

  1. #1
    Registered User
    Join Date
    06-07-2006
    Posts
    58

    Create Chart from Macro

    Hi All,
    Anyone to help me ?

    In my XL File, I have 15 Sheets
    I have created a form that contain:
    - 1 Select List (Selection of Name (1 of the 15 Sheets)
    - 1 Select List (Selection of 3 Choice (Linked to Column D, E & F)
    - 1 Button (validation)

    Could anyone help me with the Code ??

    For Example:
    Sheet 1 = TATA
    Sheet 2 = TETE
    Sheet 3 = TOTO
    Sheet 4 = .....
    For all Sheets, in Column D Values are Sum
    in Column E Values are Delta
    in Column F Values are Percent

    From the Form, if I select "TATA" & "Percent", then after clicking the Buttun, It generates a Chart with data from Column F in Sheet TATA.

    Regards
    RV
    Last edited by Herve_Rob; 01-31-2007 at 08:06 AM.

  2. #2
    Registered User
    Join Date
    01-19-2007
    Location
    Bangalore, India
    Posts
    66
    You may use this code in your Command button click event.

    Dim lr As Integer
    lr = Range(lb2.Text & 65536).End(xlUp).Row
    Charts.Add
    ActiveChart.ChartType = xlColumnClustered
    ActiveChart.SetSourceData Source:=Worksheets(lb1.Text).Range(lb2.Text & 1 & ":" & lb2.Text & lr), PlotBy _
    :=xlColumns
    ActiveChart.Location Where:=xlLocationAsNewSheet
    With ActiveChart
    .HasTitle = False
    .Axes(xlCategory, xlPrimary).HasTitle = False
    .Axes(xlValue, xlPrimary).HasTitle = False
    End With

    Here I have assumed that your Listbox which contain Sheets name is lb1 and Listbox which contains column name is lb2.

    Regards,
    Gajendra Gupta

+ 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