![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 1,290
|
Who can give me a macro that delete rows:
I have a sheet with +/- 4000 rows. If value in column C from each row is < 10 then delete entire row. Many thanks for help |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: May 2002
Location: Houston, TX
Posts: 7,184
|
Here is one we use - hope it helps.
Sub checkvalue() ' ' checkvalue Macro ' Macro recorded 6/16/01 by nt00003 ' ' If ActiveCell.Value > 10 Then deleterow movecursor End Sub Sub deleterow() Selection.EntireRow.Delete checkvalue End Sub
__________________
It's AWL Good! |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
|
This "Sheet Module" code will work from a hot-key or Form Button. For any value in Column "C" that is value less than 10 (<10) the entire row is deleted. Hope this helps. JSW
Sub DRow() 'Find all the rows for which column "C" < 0 and delete it. Application.ScreenUpdating = False Worksheets("Sheet1").Select Range("C1").Select n = 1 n = n + 1 For Each r In Worksheets("Sheet1").UsedRange.Rows n = r.Row If Worksheets("Sheet1").Cells(n, 3) < 10 Then Worksheets("Sheet1").Cells(n, 3).Select Selection.EntireRow.Delete End If Next r Application.ScreenUpdating = True 'Range("A1").Select End Sub |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
|
texasalynn,
Did you forget to include the other call code for "movecursor," this is not a standard function, method or addin? |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: May 2002
Location: Houston, TX
Posts: 7,184
|
So I did - here it is!
Sub movecursor() ActiveCell.Offset(1, 0).Range("A1").Select checkvalue End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|