ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find exact values (https://www.excelbanter.com/excel-programming/308419-find-exact-values.html)

Todd huttenstine

Find exact values
 
Hey guys


8642883054
0
8645695369
0
0
8039998989

Above is some sample data I am working with.

Below is the code that references the above sample data.
In this below code the variable "ItemValue" will represent
each of the sample data individually:

Do Until SPSave = EPSave
FndOccurances = Worksheets("SMSRD").Range("K" &
SPSave).Find(ItemValue)
If FndOccurances < Empty Then
AddFnd = AddFnd + 1
Else
End If
Loop

Lets say ItemValue = 0. My code should be returning 3 but
instead its returning 5. Its returning this because its
looking for 0 in all the values. Since 5 of the values in
the sample data contains 0s in the value, it returns 5. I
only want it to look at exact values. If it did this it
would return 3 like I need.

How do I make it look for only exact values using the code
I have supplied?

Thank you
Todd Huttenstine


Tom Ogilvy

Find exact values
 
Find has a lookat argument.

LookAt Optional Variant. Can be one of the following XlLookAt constants:
xlPart or xlWhole.



set it to xlWhole.



--

Regards,

Tom Ogilvy



"Todd Huttenstine" <anonymou
wrote in message
...
Hey guys


8642883054
0
8645695369
0
0
8039998989

Above is some sample data I am working with.

Below is the code that references the above sample data.
In this below code the variable "ItemValue" will represent
each of the sample data individually:

Do Until SPSave = EPSave
FndOccurances = Worksheets("SMSRD").Range("K" &
SPSave).Find(ItemValue)
If FndOccurances < Empty Then
AddFnd = AddFnd + 1
Else
End If
Loop

Lets say ItemValue = 0. My code should be returning 3 but
instead its returning 5. Its returning this because its
looking for 0 in all the values. Since 5 of the values in
the sample data contains 0s in the value, it returns 5. I
only want it to look at exact values. If it did this it
would return 3 like I need.

How do I make it look for only exact values using the code
I have supplied?

Thank you
Todd Huttenstine





All times are GMT +1. The time now is 11:22 AM.

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