Can I get VBA script to read a word with both lcase and ucase lett

G

Guest

Hi!
I am using this script but it can only read text with small letters. Can I
change it to read with both small and big letters:

Case Is = "i13"
If LCase(.Value) = LCase("select door") Then
'skipit
End If
 
N

Norman Jones

Hi Calle,

Using LCase on both sides of the comparison expression reders the test case
insensitive and, consequently, your code should accept the sought text in
any casr, or mix of cases.
 
G

Guest

ok, thx I try that. one more question. Is ther a way to get a script to
delete content in merged cells. I can only get the script to delete in
normal cells.

script:

Case Is = "i17"
If LCase(.Value) = LCase("clear") Then
Selection.Offset(1, -2).ClearContents
Else
 
N

Norman Jones

Hi Calle,

Try:

Case Is = "i17"
If LCase(.Value) = LCase("clear") Then
With Selection.Offset(1, -2)
If .MergeCells Then
.MergeArea.ClearContents
Else
.ClearContents
End If
End With
Else
 
D

Dave Peterson

One way:
Selection.Offset(1, -2).value = ""
ok, thx I try that. one more question. Is ther a way to get a script to
delete content in merged cells. I can only get the script to delete in
normal cells.

script:

Case Is = "i17"
If LCase(.Value) = LCase("clear") Then
Selection.Offset(1, -2).ClearContents
Else
 
D

Dave Peterson

I would think that this would work, too:
Selection.Offset(1, -2).MergeArea.ClearContents
even if the range isn't merged.

(untested, though)
 
C

Chip Pearson

If you put

Option Compare Text

at the very top of your module, text comparisons are
automatically done case-insensitive, so there is no need for the
conversion to LCase.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top