ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selection by values (https://www.excelbanter.com/excel-programming/313666-selection-values.html)

Guldo K

selection by values
 
Hello everybody.

I'd like to perform a selection by values. I mean, I have to detect,
into a given column, which cells have a certain value. I'd be happy if
I could get a range object or something with the resulting cells.

I could perform many 'Find' commands, adding the cell address to a
string on each 'Find' result, but that does not look that efficient.
I wish that 'SpecialCells' could be used, but it doesn't look
feasible, am I wrong?
Is there a better way?

Thank you.
--
Guldo


Frank Kabel

selection by values
 
Hi
AFAIK you have to use FIND statements and may use Union to create a
range of these cells

--
Regards
Frank Kabel
Frankfurt, Germany

"Guldo K" schrieb im Newsbeitrag
...
Hello everybody.

I'd like to perform a selection by values. I mean, I have to detect,
into a given column, which cells have a certain value. I'd be happy

if
I could get a range object or something with the resulting cells.

I could perform many 'Find' commands, adding the cell address to a
string on each 'Find' result, but that does not look that efficient.
I wish that 'SpecialCells' could be used, but it doesn't look
feasible, am I wrong?
Is there a better way?

Thank you.
--
Guldo



Guldo K

selection by values
 
"Frank Kabel" writes:

Hi
AFAIK you have to use FIND statements and may use Union to create a
range of these cells


Thanks. That looks just like what I needed :)
.... but I can't understand properly how to use it...
It needs Ranges as arguments, so strings do not fit.

Here's a piece of code:
'''START
Sub macro()
UNIONE = ""
NOME = "whatever"
With Sheets("foglio1").Columns(3)
PRIMO = .Find(NOME, LookIn:=xlValues, lookat:=xlWhole).Address
SUCCESSIVO = PRIMO
Do
SUCCESSIVO = .FindNext(Range(SUCCESSIVO)).Address
UNIONE = UNIONE & "Range(" & Chr(34) & SUCCESSIVO & Chr(34) & "),"
Loop Until SUCCESSIVO = PRIMO

UNIONE = Left(UNIONE, Len(UNIONE) - 1)

Union(UNIONE).Select
End With
End Sub
'''END

So, how can I pass Ranges to Union inside a loop?

Thank you.
--
Guldo


All times are GMT +1. The time now is 09:07 PM.

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