ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   match (https://www.excelbanter.com/excel-programming/360005-match.html)

peter

match
 
Hi,
I'm trying to test to see if a string exists in a range.
foundmatch = Application.WorksheetFunction.Match("wjv",
Range("staff").Value, 0)
works if range staff is a single column or row, if the range is a matrix it
returns 0
I tried useing
foundcount =
Application.WorksheetFunction.CountIf(Range("group _code").Value, "WVJ")
where group_code is more than a single row or column, it also returns 0.

Any ideas would be greatly appreciated.

peter

Tim Williams

match
 
Try dropping the ".value" from your countif example.

--
Tim Williams
Palo Alto, CA


"peter" wrote in message ...
Hi,
I'm trying to test to see if a string exists in a range.
foundmatch = Application.WorksheetFunction.Match("wjv",
Range("staff").Value, 0)
works if range staff is a single column or row, if the range is a matrix it
returns 0
I tried useing
foundcount =
Application.WorksheetFunction.CountIf(Range("group _code").Value, "WVJ")
where group_code is more than a single row or column, it also returns 0.

Any ideas would be greatly appreciated.

peter




peter

match
 
first, thanks for your help.
I took off the .value, then the range, then the quotes, nothing worked. Did
it work for you?

peter

"Tim Williams" wrote:

Try dropping the ".value" from your countif example.

--
Tim Williams
Palo Alto, CA


"peter" wrote in message ...
Hi,
I'm trying to test to see if a string exists in a range.
foundmatch = Application.WorksheetFunction.Match("wjv",
Range("staff").Value, 0)
works if range staff is a single column or row, if the range is a matrix it
returns 0
I tried useing
foundcount =
Application.WorksheetFunction.CountIf(Range("group _code").Value, "WVJ")
where group_code is more than a single row or column, it also returns 0.

Any ideas would be greatly appreciated.

peter





Tom Ogilvy

match
 
Countif only works on a range, not an array

foundcount = Application.CountIf(Range("group_code"), "WVJ")

should give you the correct count of cells that contain only the characters
WVJ in that order.

You are correct that match only works on a single column or single row.

--
Regards,
Tom Ogilvy


"peter" wrote:

first, thanks for your help.
I took off the .value, then the range, then the quotes, nothing worked. Did
it work for you?

peter

"Tim Williams" wrote:

Try dropping the ".value" from your countif example.

--
Tim Williams
Palo Alto, CA


"peter" wrote in message ...
Hi,
I'm trying to test to see if a string exists in a range.
foundmatch = Application.WorksheetFunction.Match("wjv",
Range("staff").Value, 0)
works if range staff is a single column or row, if the range is a matrix it
returns 0
I tried useing
foundcount =
Application.WorksheetFunction.CountIf(Range("group _code").Value, "WVJ")
where group_code is more than a single row or column, it also returns 0.

Any ideas would be greatly appreciated.

peter






All times are GMT +1. The time now is 12:18 AM.

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