Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2009, 11:24 PM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default Delete Rows

Hi

I have code made as below to wanted delete the Row if COL C which cell Value < 20.

Can u help me to modify or learnt me abt that’s


Thanks

Sub DeleteRows()


Columns("C:C").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete

End Sub
 
Old February 13th, 2009, 02:23 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

You can try something like the following:


Code:
Sub Delete_Rows_LEssThan20()

Dim iRow
Dim iMaxRow
iMaxRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
For iRow = 1 To iMaxRow
    If iRow > iMaxRow Then Exit Sub
    If Val(ActiveSheet.Cells(iRow, 3).Value) < 20 Then
        Rows(iRow).EntireRow.Delete
        iRow = iRow - 1
        iMaxRow = iMaxRow - 1
    End If
Next iRow
End Sub
Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips &amp; Tricks (http://www.vbadud.blogspot.com)
The Following User Says Thank You to Shasur For This Useful Post:
ks1102 (February 13th, 2009)
 
Old February 13th, 2009, 03:13 AM
Authorized User
 
Join Date: Feb 2009
Posts: 16
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks you so much


Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
How can you delete duplicate rows without using te subhasischakraborty SQL Server 2000 15 October 19th, 2007 06:51 AM
delete duplicates rows guga121 MySQL 2 June 20th, 2006 12:24 AM
delete rows miguel.ossa C# 1 August 26th, 2004 12:58 AM
Checking Duplicate values and delete rows ppenn Excel VBA 2 February 3rd, 2004 06:57 AM
Delete rows with macro? Jessica7 Beginning VB 6 1 October 15th, 2003 05:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.