Results 1 to 2 of 2

Userform that displays Charts

Threaded View

  1. #1
    Registered User
    Join Date
    04-22-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    94

    Userform that displays Charts

    I have a userform that displays charts from a worksheet, the form has a next and previous option to view each chart, this works fine if all the charts are on the same worksheet. I need to use charts for various worksheets, how can i do this?

    My code is:

    Dim ChartNum As Integer
    
    Private Sub UserForm_Initialize()
        ChartNum = 1
        UpdateChart
    End Sub
    
    Private Sub PreviousButton_Click()
        If ChartNum = 1 Then ChartNum = 3 Else ChartNum = ChartNum - 1
        UpdateChart
    End Sub
    
    Private Sub NextButton_Click()
        If ChartNum = 3 Then ChartNum = 1 Else ChartNum = ChartNum + 1
        UpdateChart
    End Sub
    
    Private Sub CloseButton_Click()
        Unload Me
    End Sub
    
    Private Sub UpdateChart()
        Set CurrentChart = Sheets("SheetName").ChartObjects(ChartNum).Chart
        CurrentChart.Parent.Width = 725
        CurrentChart.Parent.Height = 450
        
    
    '   Save chart as GIF
        Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
        CurrentChart.Export FileName:=Fname, FilterName:="GIF"
    
    '   Show the chart
        Image1.Picture = LoadPicture(Fname)
    End Sub
    Last edited by PRodgers4284; 10-16-2009 at 09:28 AM.

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