Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to search for "#N/A" in Excel VBA

I wish to write vba code that finds occurrences of #N/A, #NAME, etc in Excel
spreadsheets.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to search for "#N/A" in Excel VBA

Record a macro when you select a range (or all the cells)
edit|goto|Special
Errors

You'll be able to record a macro when you search for constants with errors and
formulas with errors. So you'll end up with two macros.

viking4020 wrote:

I wish to write vba code that finds occurrences of #N/A, #NAME, etc in Excel
spreadsheets.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default How to search for "#N/A" in Excel VBA

Use these lines in a loop stepping through the cells to be checked:
If WorksheetFunction.IsError(ActiveCell) Then
' your code
End If
Regards,
Stefi


€˛viking4020€¯ ezt Ć*rta:

I wish to write vba code that finds occurrences of #N/A, #NAME, etc in Excel
spreadsheets.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default How to search for "#N/A" in Excel VBA

On Wed, 25 Jun 2008 04:57:01 -0700, viking4020
wrote:

I wish to write vba code that finds occurrences of #N/A, #NAME, etc in Excel
spreadsheets.


Not very specific requirements, but the following should get you started:

Option Explicit
Sub foo()
Dim rStart As Range, rEnd As Range, c As Range
Set rStart = [A1]
Set rEnd = rStart.SpecialCells(xlCellTypeLastCell)

For Each c In Range(rStart, rEnd)
If IsError(c) Then
Debug.Print c.Address, c.Text
End If
Next c

End Sub
--ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default How to search for "#N/A" in Excel VBA

On Wed, 25 Jun 2008 08:41:08 -0400, Ron Rosenfeld
wrote:

On Wed, 25 Jun 2008 04:57:01 -0700, viking4020
wrote:

I wish to write vba code that finds occurrences of #N/A, #NAME, etc in Excel
spreadsheets.


Not very specific requirements, but the following should get you started:

Option Explicit
Sub foo()
Dim rStart As Range, rEnd As Range, c As Range
Set rStart = [A1]
Set rEnd = rStart.SpecialCells(xlCellTypeLastCell)

For Each c In Range(rStart, rEnd)
If IsError(c) Then
Debug.Print c.Address, c.Text
End If
Next c

End Sub
--ron


Gary's student reminded me that UsedRange was the property I really wanted:

======================
Option Explicit
Sub foo()
Dim c As Range
For Each c In ActiveSheet.UsedRange
If IsError(c) Then
Debug.Print c.Address, c.Text
End If
Next c
End Sub
====================
--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to search for "#N/A" in Excel VBA

This will find and Select all occurances of #N/A:

Sub findena()
Set ena = Nothing
For Each r In ActiveSheet.UsedRange
If r.Text = "#N/A" Then
If ena Is Nothing Then
Set ena = r
Else
Set ena = Union(ena, r)
End If
End If
Next
ena.Select
End Sub

--
Gary''s Student - gsnu200793


"viking4020" wrote:

I wish to write vba code that finds occurrences of #N/A, #NAME, etc in Excel
spreadsheets.

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
search for text "beginning with" "containing" wildcards David H Excel Worksheet Functions 1 January 13th 10 01:24 PM
=IF(ISNUMBER(SEARCH("ELB",B2)),"Pipe") add more like "ELB" "FLG" MAHMOUD Excel Worksheet Functions 5 September 6th 09 06:04 PM
How do I change the Excel "search" default to WORKBOOK & DATA? danny bromberg Excel Discussion (Misc queries) 5 July 5th 09 06:44 AM
=IF(ISERROR(SEARCH("insurance",A125,1)),"","*") cynichromantique Excel Worksheet Functions 9 September 25th 08 09:49 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM


All times are GMT +1. The time now is 10:19 AM.

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

About Us

"It's about Microsoft Excel"