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. |
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. |
All times are GMT +1. The time now is 11:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com