A Macro that Fails to Perform Correctly.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Everybody

I have created a control structure for the Show_Charts macro that tests
whether the user has entered one of the following four chart sheet names:
Orders, Net Revenue, Total Assets, or Debt. Unfortunately, when I start the
macro and type one of those chart sheet names and I click OK, the Microsoft
Visual Basic dialog box displays "Run-time error '9':
Subscript out of range"
Below is the Visual Basic code:

Sub Show_Charts()
'
'Show_Charts Macro
'This macro displays financial charts from the kiosk workbook.
'
Chartname=InputBox("Chart:Orders, Net Revenue, Total Assets, or Debt.",
"View Financial Chart.")
If Chartname="Orders" Or Chartname="Net Revenue" Or Chartname="Total Assets"
Or Chartname="Debt" Then
Charts("Chartname").Select
ElseIf Chartname <> "" Then
MsgBox "Please enter: Orders, Net Revenue, Total Assets, or
Debt.",vbInformation,"No Chart Found"
End If
End Sub

Apparently, the error is on the statement:
Charts("Chartname").Select

But I have not been successful in correcting it.
I will appreciate it if anybody can help me to correct the error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top