ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to select a range based on values in 1 column (https://www.excelbanter.com/excel-programming/338729-how-select-range-based-values-1-column.html)

ForestRamsey

How to select a range based on values in 1 column
 
I'm trying to set up a macro that will allow me to select a range of cells.
The length of the range will vary, based on the results in one column. It
could be a range with no results or possibly 150 results. (I'm sorting based
on a variety of criteria and assigning a value from 1 to 4.)

ie. A B C
address1 name 1 1
address2 name2 2
address3 name3 2
address4 name4 3

How would I tell Excel to grab a range of cells where Column C holds a value
of 2 so that I could grab the data associated with it and dump it elsewhere
for output?

Tom Ogilvy

How to select a range based on values in 1 column
 
Use the autofilter to filter on column C.

Data=Filter=Autofilter

In column C, select 2 from the dropdown
do it manually with the macro recorder on, then turn it off and check the
code.


If you copy a filtered range, only the visible cells are copied.

--
Regards,
Tom Ogilvy

"ForestRamsey" wrote in message
...
I'm trying to set up a macro that will allow me to select a range of

cells.
The length of the range will vary, based on the results in one column. It
could be a range with no results or possibly 150 results. (I'm sorting

based
on a variety of criteria and assigning a value from 1 to 4.)

ie. A B C
address1 name 1 1
address2 name2 2
address3 name3 2
address4 name4 3

How would I tell Excel to grab a range of cells where Column C holds a

value
of 2 so that I could grab the data associated with it and dump it

elsewhere
for output?




ForestRamsey

How to select a range based on values in 1 column
 
Thanks kindly for the help.

"Tom Ogilvy" wrote:

Use the autofilter to filter on column C.

Data=Filter=Autofilter

In column C, select 2 from the dropdown
do it manually with the macro recorder on, then turn it off and check the
code.


If you copy a filtered range, only the visible cells are copied.

--
Regards,
Tom Ogilvy

"ForestRamsey" wrote in message
...
I'm trying to set up a macro that will allow me to select a range of

cells.
The length of the range will vary, based on the results in one column. It
could be a range with no results or possibly 150 results. (I'm sorting

based
on a variety of criteria and assigning a value from 1 to 4.)

ie. A B C
address1 name 1 1
address2 name2 2
address3 name3 2
address4 name4 3

How would I tell Excel to grab a range of cells where Column C holds a

value
of 2 so that I could grab the data associated with it and dump it

elsewhere
for output?






All times are GMT +1. The time now is 08:41 AM.

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