ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   capital letters and cell value (https://www.excelbanter.com/excel-programming/298831-capital-letters-cell-value.html)

caroline

capital letters and cell value
 
I am trying to see if a name already exists in a list. It
works with the following code (except that it does not
recognise capital letters, for instance it will not
detect that Smith and smith are the same). I tried also
with Cell.text instead of Cell.value, but it gives me the
same problem. Any idea?

Dim Var As Range
Set Var = Range("list")
Dim Cell As Range
For Each Cell In Var
If Cell.Value = Range("newname").Value Then
MsgBox "This name already exists"
Exit Sub
End If
Next Cell

Frank Kabel

capital letters and cell value
 
Hi
change the line
If Cell.Value = Range("newname").Value Then
ro
If lcase(Cell.Value) = lcase(Range("newname").Value) Then

--
Regards
Frank Kabel
Frankfurt, Germany


caroline wrote:
I am trying to see if a name already exists in a list. It
works with the following code (except that it does not
recognise capital letters, for instance it will not
detect that Smith and smith are the same). I tried also
with Cell.text instead of Cell.value, but it gives me the
same problem. Any idea?

Dim Var As Range
Set Var = Range("list")
Dim Cell As Range
For Each Cell In Var
If Cell.Value = Range("newname").Value Then
MsgBox "This name already exists"
Exit Sub
End If
Next Cell


Don Guillett[_4_]

capital letters and cell value
 
try
If Cell.Value = Range("newname").Value Then
If ucase(Cell.Value) = ucase(Range("newname").Value) Then

--
Don Guillett
SalesAid Software

"caroline" wrote in message
...
I am trying to see if a name already exists in a list. It
works with the following code (except that it does not
recognise capital letters, for instance it will not
detect that Smith and smith are the same). I tried also
with Cell.text instead of Cell.value, but it gives me the
same problem. Any idea?

Dim Var As Range
Set Var = Range("list")
Dim Cell As Range
For Each Cell In Var
If Cell.Value = Range("newname").Value Then
MsgBox "This name already exists"
Exit Sub
End If
Next Cell




caroline

capital letters and cell value
 
Great. both suggestions lcase and ucase work
Thanks
-----Original Message-----
try
If Cell.Value = Range("newname").Value Then
If ucase(Cell.Value) = ucase(Range("newname").Value)

Then

--
Don Guillett
SalesAid Software

"caroline" wrote

in message
...
I am trying to see if a name already exists in a list.

It
works with the following code (except that it does not
recognise capital letters, for instance it will not
detect that Smith and smith are the same). I tried

also
with Cell.text instead of Cell.value, but it gives me

the
same problem. Any idea?

Dim Var As Range
Set Var = Range("list")
Dim Cell As Range
For Each Cell In Var
If Cell.Value = Range("newname").Value Then
MsgBox "This name already exists"
Exit Sub
End If
Next Cell



.



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

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