ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Define a range of rows having the same value in one column (https://www.excelbanter.com/excel-programming/374486-define-range-rows-having-same-value-one-column.html)

[email protected]

Define a range of rows having the same value in one column
 
Right now I'm looping through the sorted column and marking the
beginning row and end row of a column having a specific value and
selecting that.

But does Excel have a mechanism that does this for you?

Or perhaps, instead of selecting the rows, selects all the values in
one column having a specific value?

Even better yet would be a solution where the rows can then be deleted.

Thanks.


Don Guillett

Define a range of rows having the same value in one column
 
how about sorting or datafilterautofilter

--
Don Guillett
SalesAid Software

wrote in message
ups.com...
Right now I'm looping through the sorted column and marking the
beginning row and end row of a column having a specific value and
selecting that.

But does Excel have a mechanism that does this for you?

Or perhaps, instead of selecting the rows, selects all the values in
one column having a specific value?

Even better yet would be a solution where the rows can then be deleted.

Thanks.




Will Cairns

Define a range of rows having the same value in one column
 

wrote:
Right now I'm looping through the sorted column and marking the
beginning row and end row of a column having a specific value and
selecting that.

But does Excel have a mechanism that does this for you?

Or perhaps, instead of selecting the rows, selects all the values in
one column having a specific value?

Even better yet would be a solution where the rows can then be deleted.

Thanks.


I've used this method before..

' ------first find the value your looking for in column 'a'
ActiveSheet.Cells.Find(MyString, LookIn:=xlValues, LookAt:= _
xlWhole).Select

' -----next find how many other rows have the same value
Mycount = Application.Evaluate("=COUNTIF(A:A," & ActiveCell.Address &
")")

' ------then select all rows (and adjacent columns) where the values
are the same
Range(Selection.End(xlToRight), Selection.Offset(Mycount - 1,
0)).Select

'-------delete them if thats what you want
Selection.Delete Shift:=xlUp

Will


Will Cairns

Define a range of rows having the same value in one column
 

wrote:
Right now I'm looping through the sorted column and marking the
beginning row and end row of a column having a specific value and
selecting that.

But does Excel have a mechanism that does this for you?

Or perhaps, instead of selecting the rows, selects all the values in
one column having a specific value?

Even better yet would be a solution where the rows can then be deleted.

Thanks.


I've used this method before..

' ------first find the value your looking for in column 'a'
ActiveSheet.Cells.Find(MyString, LookIn:=xlValues, LookAt:= _
xlWhole).Select

' -----next find how many other rows have the same value
Mycount = Application.Evaluate("=COUNTIF(A:A," & ActiveCell.Address &
")")

' ------then select all rows (and adjacent columns) where the values
are the same
Range(Selection.End(xlToRight), Selection.Offset(Mycount - 1,
0)).Select

'-------delete them if thats what you want
Selection.Delete Shift:=xlUp

Will


[email protected]

Define a range of rows having the same value in one column
 
Thanks Guys.

Both tips were very helpful.



All times are GMT +1. The time now is 03:39 PM.

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