ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional row selection (https://www.excelbanter.com/excel-programming/416445-conditional-row-selection.html)

vee

Conditional row selection
 
I posted this before but can't find it, so here it is again.

I am trying to delete and entire row if column "A" contains "Void". Below
is the code that I have written. It wigs out when I try to select the entire
row.

Do While ActiveCell.Value < ""
If ActiveCell.Value = "Void" Then
ActiveRow.Select
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(1, 0).Select
End If

FSt1

Conditional row selection
 
hi
try this..
change..
activerow.select
selection.delete shift:=xlup

to....
Activecell.entirerow.delete shift:=xlup

truthfully, i don't think there is such a thing as activerow.

Regards
FSt1


"Vee" wrote:

I posted this before but can't find it, so here it is again.

I am trying to delete and entire row if column "A" contains "Void". Below
is the code that I have written. It wigs out when I try to select the entire
row.

Do While ActiveCell.Value < ""
If ActiveCell.Value = "Void" Then
ActiveRow.Select
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(1, 0).Select
End If


Mike H

Conditional row selection
 
Hi,

Right click your sheet tab, view code and paste this in. Select you data in
column A and run the macro.

Sub merse()
For Each c In Selection
If c.Value = "Void" Then
c.EntireRow.Delete
End If
Next
End Sub

Mike

"Vee" wrote:

I posted this before but can't find it, so here it is again.

I am trying to delete and entire row if column "A" contains "Void". Below
is the code that I have written. It wigs out when I try to select the entire
row.

Do While ActiveCell.Value < ""
If ActiveCell.Value = "Void" Then
ActiveRow.Select
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(1, 0).Select
End If


vee

Conditional row selection
 
Thank You - It worked

"Mike H" wrote:

Hi,

Right click your sheet tab, view code and paste this in. Select you data in
column A and run the macro.

Sub merse()
For Each c In Selection
If c.Value = "Void" Then
c.EntireRow.Delete
End If
Next
End Sub

Mike

"Vee" wrote:

I posted this before but can't find it, so here it is again.

I am trying to delete and entire row if column "A" contains "Void". Below
is the code that I have written. It wigs out when I try to select the entire
row.

Do While ActiveCell.Value < ""
If ActiveCell.Value = "Void" Then
ActiveRow.Select
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(1, 0).Select
End If


vee

Conditional row selection
 
Thanks!

"FSt1" wrote:

hi
try this..
change..
activerow.select
selection.delete shift:=xlup

to....
Activecell.entirerow.delete shift:=xlup

truthfully, i don't think there is such a thing as activerow.

Regards
FSt1


"Vee" wrote:

I posted this before but can't find it, so here it is again.

I am trying to delete and entire row if column "A" contains "Void". Below
is the code that I have written. It wigs out when I try to select the entire
row.

Do While ActiveCell.Value < ""
If ActiveCell.Value = "Void" Then
ActiveRow.Select
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(1, 0).Select
End If


RyanH

Conditional row selection
 
I would use this. This macro will scan down column A, starting in row 2, and
anytime a cell contains "Void" it will delete that row. You can change the
Column if it doesn't fit your application.

Sub DeleteRows()

Dim lngRow As Long

' start on row 2, assume header in row 1
lngRow = 2
Do While Cells(lngRow, "A").Value < ""
If Cells(lngRow, "A").Value = "Void" Then
Rows(lngRow).Delete Shift:=xlUp
End If
lngRow = lngRow + 1
Loop

End Sub

Hope this helps!
--
Cheers,
Ryan


"Vee" wrote:

Thank You - It worked

"Mike H" wrote:

Hi,

Right click your sheet tab, view code and paste this in. Select you data in
column A and run the macro.

Sub merse()
For Each c In Selection
If c.Value = "Void" Then
c.EntireRow.Delete
End If
Next
End Sub

Mike

"Vee" wrote:

I posted this before but can't find it, so here it is again.

I am trying to delete and entire row if column "A" contains "Void". Below
is the code that I have written. It wigs out when I try to select the entire
row.

Do While ActiveCell.Value < ""
If ActiveCell.Value = "Void" Then
ActiveRow.Select
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(1, 0).Select
End If



All times are GMT +1. The time now is 05:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com