473,441 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Ignore Excel formula errors using VBA

I've written a macro to remove the annoying error flags (with a green triangle in the corner and an exclamation point with a drop-down when you enter the cell) in Excel spreadsheets that have a different formula for adjacent cells:

Expand|Select|Wrap|Line Numbers
  1. Sub subIgnoreErrors(Optional ws As Worksheet)
  2. Dim cell As Range
  3. Dim intLoop As Integer
  4. Dim strEndCell as String
  5.     On Error Resume Next
  6.     If ws Is Nothing Then Set ws = ActiveSheet
  7.     strEndCell = ws.Range("A1").SpecialCells(xlCellTypeLastCell).Address
  8.     For Each cell In ws.Range("$A$1:" & strEndCell)
  9.         For intLoop = 1 To 8
  10.             cell.Errors.Item(intLoop).Ignore = True
  11.          Next
  12.      Next    
  13. End Sub
My question is, is there a way to determine the actual number of errors in the cell? Eight seems to be the magic number
Sep 20 '07 #1
2 24821
SammyB
807 Expert 512MB
There are 7:
1 xlEvaluateToError
2 xlTextDate
3 xlNumberAsText
4 xlInconsistentFormula
5 xlOmittedCells
6 xlUnlockedFormulaCells
7 xlEmptyCellReferences
See http://msdn2.microsoft.com/en-us/library/Bb236967.aspx

So, I wrote a test macro that counts the number of errors in A1:
Expand|Select|Wrap|Line Numbers
  1. Sub Macro1()
  2.     Dim cell As Range, nErrors As Integer
  3.     Set cell = [A1]
  4.     For i = 1 To 7
  5.         If cell.Errors.Item(i).Value Then nErrors = nErrors + 1
  6.     Next i
  7.     MsgBox "Cell A1 has " & nErrors & " errors."
  8. End Sub
  9.  
Sep 21 '07 #2
I don't know the version this came in, but you can now use:
ErrorCheckingOptions.NumberAsText = False
Others available as listed below.
Thanks for the info though!

There are 7:
1 xlEvaluateToError
2 xlTextDate
3 xlNumberAsText
4 xlInconsistentFormula
5 xlOmittedCells
6 xlUnlockedFormulaCells
7 xlEmptyCellReferences
See http://msdn2.microsoft.com/en-us/library/Bb236967.aspx

So, I wrote a test macro that counts the number of errors in A1:
Expand|Select|Wrap|Line Numbers
  1. Sub Macro1()
  2.     Dim cell As Range, nErrors As Integer
  3.     Set cell = [A1]
  4.     For i = 1 To 7
  5.         If cell.Errors.Item(i).Value Then nErrors = nErrors + 1
  6.     Next i
  7.     MsgBox "Cell A1 has " & nErrors & " errors."
  8. End Sub
  9.  
Feb 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: tag | last post by:
Hi, I have a problem in that I need to be able to parse excel formula's and evaluate them to get results. Python is very well suited for this as it has WONDERFUL data handling capabilities. ...
0
by: gunalan | last post by:
Hi, Can u help me to extract the excel formula functions and data type like currency,number for the corresponding cell using C#. Excepting early reply.
3
by: skiddle | last post by:
I've got an Excel formula that calculates the total business hours that a help desk ticket is open. As one would expect, it factors out holidays and non-work hours. What would be the corresponding...
1
by: =?Utf-8?B?bGF3ODc4Nw==?= | last post by:
i am looking for some MS Excel formula or MS Visal Basic Marco for converting Date to Lunar Date. tks
2
by: welshkaiboy | last post by:
Due to the size of the data I have to manipulate I need to apply a excel formula in access which determines date of manufacture from a serial number 716001 so I use...
2
by: rtilson | last post by:
I am not sure why excel and access use the same method in formula. I am not access expert but been trying to figure it out. Here is the excel formula that I would like to use in access expression...
0
by: Lina Arraiz | last post by:
I'm trying to export an Excel 2003 spreadsheet to Access 2007. I need to calculate the time elapsed between column D (START) and column E (END) with the results appearing in column F (TIME). The...
13
by: Cayetano | last post by:
How can I get this excel formula to work in access I know that the field name replaces the cell reference? Example: Clock In Clock Out = Total Time Worked ...
10
by: Cayetano | last post by:
I created a table that has a field name InTime and a field name OutTime with a calculated field name TotalTime. Now I need to create a calculated field name TotalUnits. I need to convert the excel...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.