Frncis
Member
I am using MS excel 365. I am trying to develop code to call a particular clustered column chart. Both the raw data & the chart are on the same worksheet "Unique_Vets". A friend tried to help me find code to select & call a chart from one button. I have googeled & have found code to create, copy, print charts, but none to accomplish my goal. A friend tried to help me find code to select & call a chart from one button. However when we ran the code stated below:
IF you selected 1. Nothing happened (literally nothing). I you selected 2 The charts disappeared (as in gone). the 1st chart is located @ K28, width is K28: P28, height is K28:K45. The second chart is located @ K79, width is K79: P79, height is K79:K 95.
I found a work around but it is messy :
Any help is appreciated.
Code:
Dim MyValue
Dim i As String
'MsgBox prompt:="Do you want Veterans Seen Monthly or Quarterly?",Title:="Voc. Rehab. - Career Link"
i = MsgBox("Do you want Veterans Seen Monthly or Quarterly?",vbYesNo, "Voc. Rehab. - Career Link")
If Not i = vbYes Then Exit Sub
'First message shows in the body of the box, message 2 shows at the top of thebox.
Do
MyValue = Application.InputBox("Click Ok or Cancel after yourSelection!" & vbCrLf & _
"1 = Monthly Chart" & vbCrLf & _
"2 = Quarterly Chart", "Voc. Rehab - Career Link DataEntry")
' Sub messaage box exit.
If MyValue = False Then
Exit Sub
ElseIf (MyValue = 1) Or (MyValue = 2) Then
Exit Do
Else
MsgBox "You have not made a valid entry. Please try again.",vbInformation, "Voc. Rehab. - Career Link"
End If
Loop
'Code to Execute When Condition = value_1
Select Case MyValue
Case 1
ChartObjects("Veterans Seen Quarterly").Visible = False
ChartObjects("Veterans Seen Monthly").Visible = True
'Code to Execute When Condition = value_2
Case 2
ChartObjects("Veterans Seen Monthly").Visible = False
ChartObjects("Veterans Seen Quarterly").Visible = True
End sub
I found a work around but it is messy :
Code:
Sub Vets_Seen_Charts()
Dim MyValue
Dim i As String
'MsgBox prompt:="Continue to October Career Link Meeting List?", Title:="Voc. Rehab. - Career Link"
i = MsgBox("Do you want the Vets seen Monthly or Quartrly Chart?", vbYesNo, "Voc. Rehab. - Career Link")
If Not i = vbYes Then Exit Sub
'First message shows in the body of the box, message 2 shows at the top of the box.
Do
MyValue = Application.InputBox("Which chart doyou want?" & vbCrLf & _
"1 = Vets seen Mounthly" & vbCrLf & _
"2 = Vets seen Quarterly" & vbCrLf, "Voc. Rehab. - Career Link")
' Sub messaage box exit.
If MyValue = False Then
Exit Sub
ElseIf (MyValue = 1) Or (MyValue = 2) Then
Exit Do
Else
MsgBox "You have not made a valid entry. Please try again.", vbInformation, "Voc. Rehab. - Career Link"
End If
Loop 'Code to Execute When Condition = value_1
Select Case MyValue
Case 1
If ActiveSheet.Range("A28").Select Then
Else
End If
'Code to Execute When Condition = value_2
Case 2
If ActiveSheet.Range("A79").Select Then
Else
End If
End Select
End Sub