Try code like this - you left out a lot of specifics (used ranges for specific information), so you can figure out how to modify it.
Private Sub CommandButton1_Click()
Dim rngC
Dim shtA As Worksheet
Dim chtTemp As Chart
Dim strFname As String
Dim w As Double
Dim h As Double
Dim ID As Variant
Dim rngID As Range
Dim Found As Range
Dim v As Variant
Set shtA = Worksheets("Issue Overview")
Set rngID = shtA.Columns(1) 'Column A with the ID values
ID = Me.ComboBox1.Value
If ID = "" Then
MsgBox "Select an ID. ", , "Missing Entry"
Exit Sub
End If
v = Application.Match(ID, Sheets("Comments").Range("C:C"), False)
If IsError(v) Then
MsgBox "Select a valid AIR ID.", "No Match Found"
Exit Sub
Else
Set rngC = Intersect(shtA.Range("I:Q"), shtA.Rows(Application.Match(ID, rngID, False)))
With rngC
w = .Cells(1, .Columns.Count).Left - .Cells(1, 1).Left + .Cells(1, .Columns.Count).Width
h = .Cells(.Rows.Count, 1).Top - .Cells(1, 1).Top + .Cells(.Rows.Count, 1).Height
.CopyPicture
End With
shtA.ChartObjects.Add Left:=200, Top:=50, Width:=w, Height:=h
shtA.ChartObjects(1).Activate
ActiveChart.Paste
strFname = ThisWorkbook.Path & "\" & rngC.Address & ".gif"
ActiveChart.Export Filename:=strFname, filtername:="Gif"
Me.Image1.Picture = LoadPicture(strFname)
Me.Image1.Left = (Me.Width - w) / 2
Me.Image1.Top = 50
Me.Image1.Width = w
Me.Image1.Height = h
shtA.ChartObjects(1).Delete
Set Found = Sheets("Comments").Range("C:C").Cells(v)
Found.Offset(0, -1).Value = Date & ": " & TextBox4.Text & vbCrLf & TextBox2.Text
Found.Offset(0, 1).Value = TextBox4.Text
Found.Offset(0, 2).Value = strFname
ComboBox1_Change
End If
'Update
End Sub
Bookmarks