Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error
Here's the code:
If U.Cells(i).Value = "Yes" Then Selection.Rows(i).EntireRow.Delete End If I'm trying to compare the cell value in column U to see if it equals the word "Yes" and if it is, delete the whole entire row. The error was Run-time error 424 Object require at the above code. Any suggestion is apreciated. ljCharlie --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error
Charlie,
Try something like If Cells(i,"U").Value = "Yes" Then Rows(i).Delete End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "ljCharlie " wrote in message ... Here's the code: If U.Cells(i).Value = "Yes" Then Selection.Rows(i).EntireRow.Delete End If I'm trying to compare the cell value in column U to see if it equals the word "Yes" and if it is, delete the whole entire row. The error was Run-time error 424 Object require at the above code. Any suggestion is apreciated. ljCharlie --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error
Many thanks for your help. The error is gone...but still hasn't done
what I wanted to do yet. Here's the whole code. Sub deleteDupRow() Dim Q As Range Dim x As String Set Q = Range("Q1:Q20") With Application Calculation = xlCalculationManual ScreenUpdating = False For i = 1 To Q.Rows.Count x = Q.Rows.Cells(i) If x = "Yes" Then Rows(i).Delete End If Next i End With End Sub The problem I have now is that the rows(i).delete did not delete the correct row. In addition, even if the comparison x="Yes", it's not deleting the row. Any idea why this behavior? ljCharlie --- Message posted from http://www.ExcelForum.com/ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error
When you are deleting rows in a loop, you need to start at the
bottom and work your way up. For example, For i = Q.Rows.Count To 1 Step -1 x = Q.Rows.Cells(i) If x = "Yes" Then Rows(i).Delete End If Next i -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "ljCharlie " wrote in message ... Many thanks for your help. The error is gone...but still hasn't done what I wanted to do yet. Here's the whole code. Sub deleteDupRow() Dim Q As Range Dim x As String Set Q = Range("Q1:Q20") With Application Calculation = xlCalculationManual ScreenUpdating = False For i = 1 To Q.Rows.Count x = Q.Rows.Cells(i) If x = "Yes" Then Rows(i).Delete End If Next i End With End Sub The problem I have now is that the rows(i).delete did not delete the correct row. In addition, even if the comparison x="Yes", it's not deleting the row. Any idea why this behavior? ljCharlie --- Message posted from http://www.ExcelForum.com/ |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error
Many thanks to you. It works! I just add one line to it and it works.
ljCharli -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visual Basic Error Run Time Error, Type Mismatch | Excel Discussion (Misc queries) | |||
Run time error 1004, General ODBC error | New Users to Excel | |||
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) | Excel Programming | |||
Run-time error '11' & Run-time error '1004' | Excel Programming | |||
Run-time error '11' & Run-time error '1004' | Excel Programming |