Hi all
I am trying to upload a graph into a imagebox in a userform. The code is the second part of a bigger code, thats why all variable are public
I can't seem to figure out what the issue is in my code. I am getting a "Object required" error, but as far as i can se from what ever codes i have researched i should be covered? i am unable to solve it.
I am trying to upload a graph into a imagebox in a userform. The code is the second part of a bigger code, thats why all variable are public
I can't seem to figure out what the issue is in my code. I am getting a "Object required" error, but as far as i can se from what ever codes i have researched i should be covered? i am unable to solve it.
Code:
Public co As Object
Public ct As Chart
Public sc1 As SeriesCollection
Public ser1 As Series
Public fname As String
'Public Rng As Range
Sub CreateChart()
wsUF.Activate
'lr2 = wsUF.Cells(100, "A").End(xlUp).Row
lc2 = wsUF.Cells(1, "T").End(xlToLeft).Column
Set co = wsUF.ChartObjects.Add(Range("B15").Left, Range("B15").Top, 500, 300)
co.Name = "Supplier Performance"
Set ct = co.Chart
With ct
.HasLegend = True
.HasTitle = True
.ChartTitle.Text = "Suppler Performance"
.ClearToMatchStyle
.ChartStyle = 233
Set sc1 = .SeriesCollection
Set ser1 = sc1.NewSeries
With ser1
.Name = wsUF.Cells(2, "A").Value
.XValues = Range(wsUF.Cells(1, "B"), wsUF.Cells(1, lc2 - 1))
.Values = Range(wsUF.Cells(2, "B"), wsUF.Cells(2, lc2 - 1))
.ChartType = xlLine
End With
End With
fname = ThisWorkbook.Path & "\temp.gif"
ct.Export Filename:=fname, FilterName:="gif"
Image1.Picture = LoadPicture(fname)
End Sub