Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Deleting rows with #N/A

I am using Excel 97 and want to delete rows of data which have a value of
#N/A in them which is the result from a vlookup formula.

I am using the following code but it is debugging with Type mismatch!

For i = 2 To LastRow

Cells(i, 5).Select

If Cells(i, 5).Value = "#N/A" Then
ActiveCell.EntireRow.Select
Selection.EntireRow.Delete
End If
Next i

Can anyone help with a solution, please?

--
Mark
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Deleting rows with #N/A

Okay,

But the rows with this value in will change, how do you prevent the wrong
rows being deleted?

Mark

"Nick Hodge" wrote:

Mark

Why not autofilter on that and delete the visible rows.
--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Mark" wrote in message
...
I am using Excel 97 and want to delete rows of data which have a value of
#N/A in them which is the result from a vlookup formula.

I am using the following code but it is debugging with Type mismatch!

For i = 2 To LastRow

Cells(i, 5).Select

If Cells(i, 5).Value = "#N/A" Then
ActiveCell.EntireRow.Select
Selection.EntireRow.Delete
End If
Next i

Can anyone help with a solution, please?

--
Mark




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Deleting rows with #N/A

consider modifying your vlookup first I suggest using the
if iserror function in the lookup.
example below

=IF(ISERROR(VLOOKUP(#REF!,CSR,2,FALSE))=TRUE,0,VLO OKUP
(#REF!,CSR,2,FALSE))

in the event of a error ie.. #Name..#Ref, the lookup can
put in a value like xxxxx. From here it would be easy to
identify and remove all of the undesired rows via code you
have already written.

Regards,



-----Original Message-----
I am using Excel 97 and want to delete rows of data which

have a value of
#N/A in them which is the result from a vlookup formula.

I am using the following code but it is debugging with

Type mismatch!

For i = 2 To LastRow

Cells(i, 5).Select

If Cells(i, 5).Value = "#N/A" Then
ActiveCell.EntireRow.Select
Selection.EntireRow.Delete
End If
Next i

Can anyone help with a solution, please?

--
Mark
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting rows with #N/A

Sub DeleteRows()
columns(5).SpecialCells(xlformulas,xlerrors).Entir eRow.Delete
End Sub

--
Regards,
Tom Ogilvy


"Mark" wrote in message
...
I am using Excel 97 and want to delete rows of data which have a value of
#N/A in them which is the result from a vlookup formula.

I am using the following code but it is debugging with Type mismatch!

For i = 2 To LastRow

Cells(i, 5).Select

If Cells(i, 5).Value = "#N/A" Then
ActiveCell.EntireRow.Select
Selection.EntireRow.Delete
End If
Next i

Can anyone help with a solution, please?

--
Mark





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Deleting rows with #N/A

I like Tom's suggestion best, but ...

If Cells(i, 5).Text = "#N/A" Then
or
if iserror(cells(i,5).value) then

Mark wrote:

I am using Excel 97 and want to delete rows of data which have a value of
#N/A in them which is the result from a vlookup formula.

I am using the following code but it is debugging with Type mismatch!

For i = 2 To LastRow

Cells(i, 5).Select

If Cells(i, 5).Value = "#N/A" Then
ActiveCell.EntireRow.Select
Selection.EntireRow.Delete
End If
Next i

Can anyone help with a solution, please?

--
Mark


--

Dave Peterson
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
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Excel Worksheet Functions 1 November 12th 08 01:39 PM
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
deleting hidden rows so i can print only the rows showing?????? jenn Excel Worksheet Functions 0 October 6th 05 04:05 PM


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