Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Replacing "error msg" in VBa
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Chip Pearson, post: 6421546"] An error value is a special type of Variant, not the string "#N/A" (or one of the other error values). You can't do a Replace operation with an error type as the Find value, so you'll need to use a loop to find the #N/A cells. To get an error type of test against the cell values, you use the CVErr function to convert the error number to an error type variant. For example, Dim R As Range For Each R In Range("A1:F10").SpecialCells(xlCellTypeFormulas) If R.Value = CVErr(xlErrNA) Then R.Value = "replaced" End If Next R This will replace all the #N/A errors in cells with a formula with the string "replaced". Change "replaced" to whatever you want to replace the #N/A values with. An Error 2042 is the representation of an #N/A error. The constant value xlErrNA is a Long type value equal to the number 2042. When that number is passed to CVErr, CVErr returns the corresponding Error Type variable, an #N/A error. Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2010 Pearson Software Consulting, LLC [URL="http://www.cpearson.com"]www.cpearson.com[/URL] (email on web site) [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Replacing "error msg" in VBa
Top