PC Review


Reply
Thread Tools Rate Thread

Deleting Rows Based on Column Critieria

 
 
blackmanofsteel40
Guest
Posts: n/a
 
      12th Sep 2007
Basically, I'm trying to delete the entire row in my worksheet if
Columns F-P are all blank. I have this macro written so far, but I'm
can't seem to decipher what I'm missing to have it work. Thanks in
advance for helping with my novice programming.

Sub Gift()

With .Cells(Lrow, "F")


If Application.CountA(.Range(.Cells(Lrow,
"F"), .Cells(Lrow, "P"))) = 0 Then .Rows(Lrow).Delete


End With
End Sub

 
Reply With Quote
 
 
 
 
blackmanofsteel40
Guest
Posts: n/a
 
      12th Sep 2007
On Sep 12, 11:08 am, blackmanofsteel40 <blackmanofstee...@gmail.com>
wrote:
> Basically, I'm trying to delete the entire row in my worksheet if
> Columns F-P are all blank. I have this macro written so far, but I'm
> can't seem to decipher what I'm missing to have it work. Thanks in
> advance for helping with my novice programming.
>
> Sub Gift()
>
> With .Cells(Lrow, "F")
>
> If Application.CountA(.Range(.Cells(Lrow,
> "F"), .Cells(Lrow, "P"))) = 0 Then .Rows(Lrow).Delete
>
> End With
> End Sub




Sorry is the full code that I'm having problems with:

Sub Loop_Example()
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

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow =
ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row

For Lrow = Lastrow To Firstrow Step -1

If Application.CountA(.Range(.Cells(Lrow, "F"), .Cells(Lrow,
"P"))) = 0 Then .Rows(Lrow).Delete


Next Lrow

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      12th Sep 2007
Sub Gift()
Dim r as Range, lrow as Long, i as Long
set r = ActiveSheet.UsedRange
lrow = r.rows(r.rows.count).row

for i = lrow to 1 step -1
With ActiveSheet


If Application.CountA(.Range(.Cells(i,"F"), _
.Cells(i, "P"))) = 0 Then
.Rows(i).Delete
end if

End With
Next i
End Sub

--
Regards,
Tom Ogilvy



"blackmanofsteel40" wrote:

> Basically, I'm trying to delete the entire row in my worksheet if
> Columns F-P are all blank. I have this macro written so far, but I'm
> can't seem to decipher what I'm missing to have it work. Thanks in
> advance for helping with my novice programming.
>
> Sub Gift()
>
> With .Cells(Lrow, "F")
>
>
> If Application.CountA(.Range(.Cells(Lrow,
> "F"), .Cells(Lrow, "P"))) = 0 Then .Rows(Lrow).Delete
>
>
> End With
> End Sub
>
>

 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      12th Sep 2007
Go back to the website and look good at the example code
http://www.rondebruin.nl/delete.htm

You delete a lot of the code in the macro

See below the macro on my site which part you must replace with the
code you want to try.




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"blackmanofsteel40" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> On Sep 12, 11:08 am, blackmanofsteel40 <blackmanofstee...@gmail.com>
> wrote:
>> Basically, I'm trying to delete the entire row in my worksheet if
>> Columns F-P are all blank. I have this macro written so far, but I'm
>> can't seem to decipher what I'm missing to have it work. Thanks in
>> advance for helping with my novice programming.
>>
>> Sub Gift()
>>
>> With .Cells(Lrow, "F")
>>
>> If Application.CountA(.Range(.Cells(Lrow,
>> "F"), .Cells(Lrow, "P"))) = 0 Then .Rows(Lrow).Delete
>>
>> End With
>> End Sub

>
>
>
> Sorry is the full code that I'm having problems with:
>
> Sub Loop_Example()
> 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
>
> Firstrow = ActiveSheet.UsedRange.Cells(1).Row
> Lastrow =
> ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row
>
> For Lrow = Lastrow To Firstrow Step -1
>
> If Application.CountA(.Range(.Cells(Lrow, "F"), .Cells(Lrow,
> "P"))) = 0 Then .Rows(Lrow).Delete
>
>
> Next Lrow
>
> ActiveWindow.View = ViewMode
> With Application
> .ScreenUpdating = True
> .Calculation = CalcMode
> End With
>
> End Sub
>

 
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
how to count entries in one column based on critieria in another c jw Microsoft Excel Misc 4 27th May 2009 07:12 AM
how to count entries in one column based on critieria in another c jw Microsoft Excel Misc 0 27th May 2009 06:48 AM
Deleting rows based on column values Dazed and Confused Microsoft Excel New Users 3 6th Feb 2009 10:47 PM
Deleting Rows based on Column Critieria blackmanofsteel40 Microsoft Excel Misc 1 7th Sep 2007 09:05 PM
Deleting rows based upon the value in column D =?Utf-8?B?U2Vhbg==?= Microsoft Excel Programming 2 25th Oct 2004 08:59 PM


Features
 

Advertising
 

Newsgroups
 


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