Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Delete Rows then Move Up

Hi...

I have 3000 records. In column B there are sporadic #N/A values. I need some
nicely packaged code that will delete all rows where a #N/A appears in B, so
that there are no gaps in the rows. Sounds easy but I'm struggling.

Any help would be most appreciated.

Thanks

Gordon...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Delete Rows then Move Up

In the Worksheet module:


Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If MyCell.Value = "N/A#" Then
MyCell.EntireRow.Delete
End If
Next
End Sub

Gordon wrote:
Hi...

I have 3000 records. In column B there are sporadic #N/A values. I need some
nicely packaged code that will delete all rows where a #N/A appears in B, so
that there are no gaps in the rows. Sounds easy but I'm struggling.

Any help would be most appreciated.

Thanks

Gordon...


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Delete Rows then Move Up

Hi...

The procedure stops on this line: Run-time error 13 Type mismatch

If MyCell.Value = "#N/A" Then

Any clues?

Thanks in advance...

Gordon...



" wrote:

In the Worksheet module:


Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If MyCell.Value = "N/A#" Then
MyCell.EntireRow.Delete
End If
Next
End Sub

Gordon wrote:
Hi...

I have 3000 records. In column B there are sporadic #N/A values. I need some
nicely packaged code that will delete all rows where a #N/A appears in B, so
that there are no gaps in the rows. Sounds easy but I'm struggling.

Any help would be most appreciated.

Thanks

Gordon...



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Delete Rows then Move Up

Try this. It looks for the N/A error.

Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If Application.WorksheetFunction.IsNA(MyCell) = True Then
MyCell.EntireRow.Delete
End If
Next
End Sub


Gordon wrote:
Hi...

The procedure stops on this line: Run-time error 13 Type mismatch

If MyCell.Value = "#N/A" Then

Any clues?

Thanks in advance...

Gordon...



" wrote:

In the Worksheet module:


Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If MyCell.Value = "N/A#" Then
MyCell.EntireRow.Delete
End If
Next
End Sub

Gordon wrote:
Hi...

I have 3000 records. In column B there are sporadic #N/A values. I need some
nicely packaged code that will delete all rows where a #N/A appears in B, so
that there are no gaps in the rows. Sounds easy but I'm struggling.

Any help would be most appreciated.

Thanks

Gordon...




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Delete Rows then Move Up

Gordon,

Try this. It checks for the N/A error.

Alan

Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If Application.WorksheetFunction.IsNA(MyCell) = True Then
MyCell.EntireRow.Delete
End If
Next
End Sub


Gordon wrote:
Hi...

The procedure stops on this line: Run-time error 13 Type mismatch

If MyCell.Value = "#N/A" Then

Any clues?

Thanks in advance...

Gordon...



" wrote:

In the Worksheet module:


Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If MyCell.Value = "N/A#" Then
MyCell.EntireRow.Delete
End If
Next
End Sub

Gordon wrote:
Hi...

I have 3000 records. In column B there are sporadic #N/A values. I need some
nicely packaged code that will delete all rows where a #N/A appears in B, so
that there are no gaps in the rows. Sounds easy but I'm struggling.

Any help would be most appreciated.

Thanks

Gordon...






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Delete Rows then Move Up

Hi...

Thought about it for 30 seconds, the screen flickered, but then it did
nothing...

Any clues?

Cheers

Gordon...

" wrote:

Gordon,

Try this. It checks for the N/A error.

Alan

Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If Application.WorksheetFunction.IsNA(MyCell) = True Then
MyCell.EntireRow.Delete
End If
Next
End Sub


Gordon wrote:
Hi...

The procedure stops on this line: Run-time error 13 Type mismatch

If MyCell.Value = "#N/A" Then

Any clues?

Thanks in advance...

Gordon...



" wrote:

In the Worksheet module:


Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If MyCell.Value = "N/A#" Then
MyCell.EntireRow.Delete
End If
Next
End Sub

Gordon wrote:
Hi...

I have 3000 records. In column B there are sporadic #N/A values. I need some
nicely packaged code that will delete all rows where a #N/A appears in B, so
that there are no gaps in the rows. Sounds easy but I'm struggling.

Any help would be most appreciated.

Thanks

Gordon...




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Delete Rows then Move Up

I ran it on some test data and it worked fine. I will take a look at
it again. Do you have any other code that may be firing as a result of
changes in the worksheet?


Gordon wrote:
Hi...

Thought about it for 30 seconds, the screen flickered, but then it did
nothing...

Any clues?

Cheers

Gordon...

" wrote:

Gordon,

Try this. It checks for the N/A error.

Alan

Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If Application.WorksheetFunction.IsNA(MyCell) = True Then
MyCell.EntireRow.Delete
End If
Next
End Sub


Gordon wrote:
Hi...

The procedure stops on this line: Run-time error 13 Type mismatch

If MyCell.Value = "#N/A" Then

Any clues?

Thanks in advance...

Gordon...



" wrote:

In the Worksheet module:


Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If MyCell.Value = "N/A#" Then
MyCell.EntireRow.Delete
End If
Next
End Sub

Gordon wrote:
Hi...

I have 3000 records. In column B there are sporadic #N/A values. I need some
nicely packaged code that will delete all rows where a #N/A appears in B, so
that there are no gaps in the rows. Sounds easy but I'm struggling.

Any help would be most appreciated.

Thanks

Gordon...





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete Rows then Move Up

Sub DeleteNA()
With Activesheet
On Error Resume Next
.columns(2).SpecialCells(xlFormulas,xlErrors).Enti reRow.Delete
On Error goto 0
End With
End Sub

--
Regards,
Tom Ogilvy



wrote in message
ups.com...
I ran it on some test data and it worked fine. I will take a look at
it again. Do you have any other code that may be firing as a result of
changes in the worksheet?


Gordon wrote:
Hi...

Thought about it for 30 seconds, the screen flickered, but then it did
nothing...

Any clues?

Cheers

Gordon...

" wrote:

Gordon,

Try this. It checks for the N/A error.

Alan

Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If Application.WorksheetFunction.IsNA(MyCell) = True Then
MyCell.EntireRow.Delete
End If
Next
End Sub


Gordon wrote:
Hi...

The procedure stops on this line: Run-time error 13 Type mismatch

If MyCell.Value = "#N/A" Then

Any clues?

Thanks in advance...

Gordon...



" wrote:

In the Worksheet module:


Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If MyCell.Value = "N/A#" Then
MyCell.EntireRow.Delete
End If
Next
End Sub

Gordon wrote:
Hi...

I have 3000 records. In column B there are sporadic #N/A values.
I need some
nicely packaged code that will delete all rows where a #N/A
appears in B, so
that there are no gaps in the rows. Sounds easy but I'm
struggling.

Any help would be most appreciated.

Thanks

Gordon...







  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Delete Rows then Move Up

Hi Tom...

The #N/A that I need deleting was being created by an error response to a
vlookup table. By using iserror in my formula the #n/a is now a 1. I think
deleting #n/a's was too problematic. Is it easier to delete rows where a 1
occours in column b, rather than #n/a's?

Thanks

Gordon

"Tom Ogilvy" wrote:

Sub DeleteNA()
With Activesheet
On Error Resume Next
.columns(2).SpecialCells(xlFormulas,xlErrors).Enti reRow.Delete
On Error goto 0
End With
End Sub

--
Regards,
Tom Ogilvy



wrote in message
ups.com...
I ran it on some test data and it worked fine. I will take a look at
it again. Do you have any other code that may be firing as a result of
changes in the worksheet?


Gordon wrote:
Hi...

Thought about it for 30 seconds, the screen flickered, but then it did
nothing...

Any clues?

Cheers

Gordon...

" wrote:

Gordon,

Try this. It checks for the N/A error.

Alan

Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If Application.WorksheetFunction.IsNA(MyCell) = True Then
MyCell.EntireRow.Delete
End If
Next
End Sub


Gordon wrote:
Hi...

The procedure stops on this line: Run-time error 13 Type mismatch

If MyCell.Value = "#N/A" Then

Any clues?

Thanks in advance...

Gordon...



" wrote:

In the Worksheet module:


Sub Delete_NA()
Dim MyCell As Range
For Each MyCell In Range("B1:B3000")
If MyCell.Value = "N/A#" Then
MyCell.EntireRow.Delete
End If
Next
End Sub

Gordon wrote:
Hi...

I have 3000 records. In column B there are sporadic #N/A values.
I need some
nicely packaged code that will delete all rows where a #N/A
appears in B, so
that there are no gaps in the rows. Sounds easy but I'm
struggling.

Any help would be most appreciated.

Thanks

Gordon...








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 to delete blank rows and move data/info samoan Excel Discussion (Misc queries) 3 September 19th 08 04:50 PM
Delete and Move Up Gordon[_2_] Excel Programming 4 September 29th 06 04:00 PM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM
Button to move row and delete old row Stacie Fugate[_2_] Excel Programming 12 January 27th 05 09:25 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 11:02 PM.

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"