+ Reply to Thread
Results 1 to 9 of 9

Chart displayed is selected via a dropdown menu

Hybrid View

Buster1320 Chart displayed is selected... 05-14-2008, 02:50 AM
royUK Buster, please read the... 05-14-2008, 03:50 AM
Buster1320 I have read the forum... 05-14-2008, 11:33 AM
royUK Your error is because you... 05-14-2008, 11:55 AM
royUK I've moved the code & changed... 05-14-2008, 12:04 PM
  1. #1
    Registered User
    Join Date
    05-14-2008
    Posts
    7

    Chart displayed is selected via a dropdown menu

    I have a workbook with several sheets of data and charts... I want to be able to hide all of the data sheets and individual charts so that when someone opens the workbook they only see a single sheet. I want the individual that opens the workbook to select from a dropdown menu and *poof* that chart is displated on the "front page".... I am pretty proficient with Excel, but not with VBA or the use of Macros. I found the below code, which appears todo want I want.... But it doesn't work. Is there something that I need todo in order for the code to "run"? I need to be able to send these files to others and have it work without them doing anything "special"....

    The code I found...
    Private Sub Worksheet_Change(ByVal Target As Range)
       Dim chartToCopy As ChartObject
    'launch macro when InCell dropdown in E3 changes
       If Target.Address = Range("e3").Address Then
    'delete existing chart
           If Me.ChartObjects.Count > 0 Then
               Me.ChartObjects(1).Delete
           End If
           If Target = "Branch1" Then
               Set chartToCopy = Sheets("Sheet1").ChartObjects(1)
           ElseIf Target = "Branch2" Then
               Set chartToCopy = Sheets("Sheet2").ChartObjects(1)
           Else
               End
           End If
           chartToCopy.Copy
           Me.Paste Range("c5")
           Application.CutCopyMode = False
       End If
    End Sub

    Thanks!
    Buster
    Last edited by royUK; 05-14-2008 at 03:51 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Buster, please read the Forum Rules and use Code Tags in future. I will add them for you this time.

    Have you amended the code to work with your sheet & chart names?
    Last edited by royUK; 05-14-2008 at 03:52 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    05-14-2008
    Posts
    7
    Quote Originally Posted by royUK
    Buster, please read the Forum Rules and use Code Tags in future. I will add them for you this time.

    Have you amended the code to work with your sheet & chart names?
    I have read the forum rules.... Thanks for the help with wraping my code and making it appear as the rules state. I do not know anything about VBA/code so I was unsure what I really needed todo in order to follow the rules.

    So, as I posted before, I am not even at the novice level with VBA...

    I did amend the code to work with my sheets and charts.... That did not work, so I built a chart/sheet combo based on the VBA code that I found, and that does not work either.

    I don't know if I need todo this or not, but when I compile the code, it tells me that there is an invalid use of Me on the first instance of it. Since I don't know what a valid use is, I am lost already.

    Is there something that I need todo in order for the code to run?

    I have attached the xls file with the sample that I built based on the code that I found...

    Thanks for all of the help!
    Buster
    Attached Files Attached Files

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your error is because you placed the worksheet code in a standard module. I'll take a look at it later

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I've moved the code & changed it slightly
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-14-2008
    Posts
    7
    Quote Originally Posted by royUK
    I've moved the code & changed it slightly
    royUK,

    It works! So what did I do wrong as I build the code into the sheet/combo chart that I have? You said I placed it in a standard module, I just used the insert module from the editor, what do I need to do?

    Thanks for the help!

    Buster

    EDIT
    --------------------------------------------
    I figured it out!! I needed to view the code for the sheet and then add the VBA there.....

    This is pretty powerful stuff!!! I need to figure out how todo more of this in Excel.

    Again, thanks for the help!
    Last edited by Buster1320; 05-14-2008 at 02:45 PM.

+ 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