Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KMH KMH is offline
external usenet poster
 
Posts: 31
Default Simple VBA Code Working in Excel 2007 but not Excel 2003 #N/A

I have a fairly simple VBA subroutine that turns data labels on/off on a
stacked bar chart as long as the value is not 0 or NA it turns on. The macro
works perfectly in Excel 2007, but stops on the first #N/A value.
The code stops on one of the following 2 simple commands.

Series = Cells(RowNumStart + X - 1, SeriesCol).Value
If WorksheetFunction.IsNA(Cells(RowNumStart + X - 1, ColNum)) Then

What could be causing this. I have checked that the location in the Cells
location is correct. Just as an FYI, this whole macro wasn't required in
Excel 2007 because Excel 2007 won't chart the #N/A value at all, but Excel
2003 charts it as a 0 value. Thanks for your help.
K
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Simple VBA Code Working in Excel 2007 but not Excel 2003 #N/A

The IsNA function is new in 2007, which is why your code fails in 2003. Try
something like this

Dim bIsNA As Boolean

With Cells(RowNumStart + X - 1, SeriesCol)
bIsNA = False ' be sure to initialize
If varType(.value) = vbError Then
bIsNA = .Value = CVErr(xlErrNA) Then
End if
' If bIsNa then ' ?

End with

This would probably be faster in 2007 than using the worksheet function

Not sure what your line starting Series = is intended for

' Excel 2003 charts it as a 0 value.
Assuming you are talking about a Line chart #N/A should be interpolated, as
in 2007. Also, with the chart selected, look at Tools, Options, Chart, Plot
empty cells as.

Regards,
Peter T






"KMH" wrote in message
...
I have a fairly simple VBA subroutine that turns data labels on/off on a
stacked bar chart as long as the value is not 0 or NA it turns on. The
macro
works perfectly in Excel 2007, but stops on the first #N/A value.
The code stops on one of the following 2 simple commands.

Series = Cells(RowNumStart + X - 1, SeriesCol).Value
If WorksheetFunction.IsNA(Cells(RowNumStart + X - 1, ColNum)) Then

What could be causing this. I have checked that the location in the Cells
location is correct. Just as an FYI, this whole macro wasn't required in
Excel 2007 because Excel 2007 won't chart the #N/A value at all, but Excel
2003 charts it as a 0 value. Thanks for your help.
K



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
Code in 2003 not working in 2007 GregK Excel Programming 9 September 18th 08 12:55 PM
2007 code not working in 2003 Imran J Khan Excel Programming 5 September 2nd 08 09:00 PM
Simple Excel 2003 macro not working in Excel 2007 Bryan Excel Programming 0 June 19th 08 02:33 PM
Simple VBA Code written in Excel 2003 not working in Excel 2000 Rich B. Excel Programming 4 August 3rd 07 04:36 PM
Excel 2003 won't run simple code that Excel XP and Excel 2000 will run Moses[_2_] Excel Programming 4 January 27th 05 06:30 AM


All times are GMT +1. The time now is 07:12 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"