Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 fails to calculate cells correctly Toi Excel Discussion (Misc queries) 2 May 7th 07 06:47 AM
1-variable Data Table dependent on MS Query fails to update correctly [email protected] Excel Discussion (Misc queries) 0 March 30th 05 07:43 PM
Macro Fails to Run Correctly JK Excel Programming 3 August 20th 04 09:40 PM
Macro doesn't perform correctly when using right click menu David Cuthill[_2_] Excel Programming 2 July 26th 04 06:15 PM
Macro fails without VB help files Michael Miazga[_2_] Excel Programming 0 July 22nd 03 04:10 PM


All times are GMT +1. The time now is 03:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"