ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search column for a value (https://www.excelbanter.com/excel-programming/387165-search-column-value.html)

JRForm

Search column for a value
 
I am searching a column of values for a specific value.
How can I search for case sensitive data values?

Here is the code I am using;
Do Until ActiveCell = ""
If ActiveCell = strSearch Then
bolFound = True
Exit Sub
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

Thanks


Tom Ogilvy

Search column for a value
 
You code is already case sensitive if you have added a line like

Option Compare Text

at the top of the module


ActiveCell = strSearch

is a case sensitive comparison.

to demo from the immediate window:

? "ABC" = "abc"
False
? "ABC" = "ABC"
True

--
Regards,
Tom Ogilvy



"JRForm" wrote:

I am searching a column of values for a specific value.
How can I search for case sensitive data values?

Here is the code I am using;
Do Until ActiveCell = ""
If ActiveCell = strSearch Then
bolFound = True
Exit Sub
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

Thanks


Jim Thomlinson

Search column for a value
 
How about this... You can change xlFormulas/xlValues, xlPart/xlWhole,
MatchCase True/False...

Sub FindStuff()
Dim rngFound As Range
Dim strSearch As String

strSearch = "Tada"
Set rngFound = Columns("B").Find(What:=strSearch, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
MatchCase:=True)
If Not rngFound Is Nothing Then rngFound.Select
End Sub
--
HTH...

Jim Thomlinson


"JRForm" wrote:

I am searching a column of values for a specific value.
How can I search for case sensitive data values?

Here is the code I am using;
Do Until ActiveCell = ""
If ActiveCell = strSearch Then
bolFound = True
Exit Sub
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

Thanks


Tom Ogilvy

Search column for a value
 
This line
You code is already case sensitive if you have added a line like
should say

Your code is already case sensitive if you have NOT added a line like

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote:

You code is already case sensitive if you have added a line like

Option Compare Text

at the top of the module


ActiveCell = strSearch

is a case sensitive comparison.

to demo from the immediate window:

? "ABC" = "abc"
False
? "ABC" = "ABC"
True

--
Regards,
Tom Ogilvy



"JRForm" wrote:

I am searching a column of values for a specific value.
How can I search for case sensitive data values?

Here is the code I am using;
Do Until ActiveCell = ""
If ActiveCell = strSearch Then
bolFound = True
Exit Sub
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

Thanks


JRForm

Search column for a value
 
Thank you :)

"Tom Ogilvy" wrote:

You code is already case sensitive if you have added a line like

Option Compare Text

at the top of the module


ActiveCell = strSearch

is a case sensitive comparison.

to demo from the immediate window:

? "ABC" = "abc"
False
? "ABC" = "ABC"
True

--
Regards,
Tom Ogilvy



"JRForm" wrote:

I am searching a column of values for a specific value.
How can I search for case sensitive data values?

Here is the code I am using;
Do Until ActiveCell = ""
If ActiveCell = strSearch Then
bolFound = True
Exit Sub
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

Thanks


JRForm

Search column for a value
 
Thank you:)


"Jim Thomlinson" wrote:

How about this... You can change xlFormulas/xlValues, xlPart/xlWhole,
MatchCase True/False...

Sub FindStuff()
Dim rngFound As Range
Dim strSearch As String

strSearch = "Tada"
Set rngFound = Columns("B").Find(What:=strSearch, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
MatchCase:=True)
If Not rngFound Is Nothing Then rngFound.Select
End Sub
--
HTH...

Jim Thomlinson


"JRForm" wrote:

I am searching a column of values for a specific value.
How can I search for case sensitive data values?

Here is the code I am using;
Do Until ActiveCell = ""
If ActiveCell = strSearch Then
bolFound = True
Exit Sub
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

Thanks



All times are GMT +1. The time now is 01:55 AM.

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