Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
A Macro that Fails to Perform Correctly.
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
A Macro that Fails to Perform Correctly.
remove the quotes from around charts("chartname") shoudl be
charts(chartname) "Almamba" wrote: 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2003 fails to calculate cells correctly | Excel Discussion (Misc queries) | |||
1-variable Data Table dependent on MS Query fails to update correctly | Excel Discussion (Misc queries) | |||
Macro Fails to Run Correctly | Excel Programming | |||
Macro doesn't perform correctly when using right click menu | Excel Programming | |||
Macro fails without VB help files | Excel Programming |