Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default Delete row if cell has nothing

Hello,

I woulk like to delete row when in your cell the value is N/A#

This is my code

I have a bi-dimensional var (1 to 1000, 1 to 9) as variant


For n = LBound(var) To UBound(var)

Do
Set rng = Range("A:A").Find(What:="N/A#", _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
rng.EntireRow.Delete

Loop While Not (rng Is Nothing)

Next n

this is the row

MARIANNE | DATE| N/A# | 125.-

I would like to delete this row do you think you need to use cell

ina

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete row if cell has nothing

Sub DeleteNAs()
Dim oCell As Range
Dim rng As Range
Dim rngDelete As Range

On Error Resume Next
Set rng = ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormu las, 16)
On Error GoTo 0

If Not rng Is Nothing Then
For Each oCell In rng
If IsError(oCell.Value) Then
If oCell.Value = CVErr(xlErrNA) Then
If rngDelete Is Nothing Then
Set rngDelete = oCell
Else
Set rngDelete = Union(oCell, rngDelete)
End If
End If
End If
Next oCell
End If

If Not rngDelete Is Nothing Then rngDelete.EntireRow.Delete

End Sub


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"ina" wrote in message
oups.com...
Hello,

I woulk like to delete row when in your cell the value is N/A#

This is my code

I have a bi-dimensional var (1 to 1000, 1 to 9) as variant


For n = LBound(var) To UBound(var)

Do
Set rng = Range("A:A").Find(What:="N/A#", _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
rng.EntireRow.Delete

Loop While Not (rng Is Nothing)

Next n

this is the row

MARIANNE | DATE| N/A# | 125.-

I would like to delete this row do you think you need to use cell

ina



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 329
Default Delete row if cell has nothing

Hi ina,

Assuming UBound(Var) To LBound(Var) is meant to define the rows to search,
try:

Sub CleanUp()
Dim R As Long
Dim C As Integer
With ActiveSheet
For R = UBound(Var) To LBound(Var) Step -1
For C = 1 To .UsedRange.Columns.Count
If .Cells(R, C).Text = "#N/A" Then
.Rows(R).EntireRow.Delete
Exit For
End If
Next C
Next R
End With
End Sub

Cheers


"ina" wrote in message
oups.com...
Hello,

I woulk like to delete row when in your cell the value is N/A#

This is my code

I have a bi-dimensional var (1 to 1000, 1 to 9) as variant


For n = LBound(var) To UBound(var)

Do
Set rng = Range("A:A").Find(What:="N/A#", _
After:=Range("A" & Rows.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
rng.EntireRow.Delete

Loop While Not (rng Is Nothing)

Next n

this is the row

MARIANNE | DATE| N/A# | 125.-

I would like to delete this row do you think you need to use cell

ina



  #4   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default Delete row if cell has nothing

thank you a lot for this two answers
:) Ina

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
Weird: inside of a cell I have a small box or cell I can't delete. ACECOWBOY Excel Discussion (Misc queries) 4 May 2nd 23 03:43 AM
How to delete cell values withour deleting cell formulae perfection Excel Discussion (Misc queries) 5 June 18th 07 09:05 PM
How to delete cell values without affecting cell formulae perfection Excel Discussion (Misc queries) 0 June 18th 07 06:55 AM
Delete cell on 1 page: automatically delete on another page? mountain view Excel Worksheet Functions 0 September 28th 06 04:18 PM
Delete cell contents with input to adjacent cell Ashley Frank Excel Discussion (Misc queries) 1 October 5th 05 04:28 PM


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