PC Review


Reply
Thread Tools Rate Thread

Delete row if value does not exist

 
 
Freddy
Guest
Posts: n/a
 
      26th Nov 2007
I am using the below code to look down a column of values and if the value =
0, then delete the entire row.

I now have a list of 466 places on one sheet and a summary sheet with 8-10
laces

Would anyone know how to change the code to now look down the summary sheet
and then delete all those rows of places on the 1st sheets that are not on
the summary sheet

Your help is greatly appreciated

Code:


Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = 5
Lastrow = 466
For Lrow = Lastrow To Firstrow Step -1
With .Cells(Lrow, "B")
If Not IsError(.Value) Then
If .Value = 0 Then .EntireRow.Delete
End If
End With
Next Lrow
End With
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      26th Nov 2007
Check the column in code below to see if they are correct. Code is search
column A on activesheet and summary sheet.

Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
.DisplayPageBreaks = False
Firstrow = 5
Lastrow = 466
For Lrow = Lastrow To Firstrow Step -1
data = .Cells(Lrow, "A")
with sheets("summary")
set c = .columns("A:A").find(what:=data, lookin:=xlvalues)

if not c is nothing then
c.entirerow.delete
End If
End With
Next Lrow
End With

"Freddy" wrote:

> I am using the below code to look down a column of values and if the value =
> 0, then delete the entire row.
>
> I now have a list of 466 places on one sheet and a summary sheet with 8-10
> laces
>
> Would anyone know how to change the code to now look down the summary sheet
> and then delete all those rows of places on the 1st sheets that are not on
> the summary sheet
>
> Your help is greatly appreciated
>
> Code:
>
>
> Dim Firstrow As Long
> Dim Lastrow As Long
> Dim Lrow As Long
> Dim CalcMode As Long
> Dim ViewMode As Long
> With Application
> CalcMode = .Calculation
> .Calculation = xlCalculationManual
> .ScreenUpdating = False
> End With
> With ActiveSheet
> .Select
> ViewMode = ActiveWindow.View
> ActiveWindow.View = xlNormalView
> .DisplayPageBreaks = False
> Firstrow = 5
> Lastrow = 466
> For Lrow = Lastrow To Firstrow Step -1
> With .Cells(Lrow, "B")
> If Not IsError(.Value) Then
> If .Value = 0 Then .EntireRow.Delete
> End If
> End With
> Next Lrow
> End With

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How do I delete files that no longer exist? Tom Ferguson Windows Vista File Management 0 23rd Mar 2009 10:43 PM
delete records that exist in another table gymphil Microsoft Access Queries 4 29th Aug 2008 09:04 AM
Delete row if no date exist =?Utf-8?B?VEhFX1JBTU9ORVM=?= Microsoft Excel Programming 7 29th Mar 2006 03:25 PM
delete sheet if it exist Art Parra Microsoft Excel Programming 2 7th Feb 2006 04:16 PM
It appears to exist, but I can't delete it Matt Windows XP General 1 15th Jan 2004 04:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:08 PM.