Microsoft Office Tutorials and References
In Depth Information
Displaying a Chart in a UserForm
Displaying a Chart in a UserForm
In Chapter 15, I describe a way to display a chart in a UserForm. The technique saves the chart as
a GIF file and then loads the GIF file into an Image control on the UserForm.
The example in this section uses that same technique but adds a new twist: The chart is created
on the fly and uses the data in the row of the active cell. Figure 18-11 shows an example.
Figure 18-11: The chart in this UserForm is created on the fly from the data in the active row.
The UserForm for this example is very simple. It contains an Image control and a CommandButton
(Close). The worksheet that contains the data has a button that executes the following procedure:
Sub ShowChart()
Dim UserRow As Long
UserRow = ActiveCell.Row
If UserRow < 2 Or IsEmpty(Cells(UserRow, 1)) Then
MsgBox “Move the cell pointer to a row that contains data.”
Exit Sub
End If
CreateChart (UserRow)
End Sub
Search JabSto ::

Custom Search