ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I test for the first character (https://www.excelbanter.com/excel-programming/312106-how-do-i-test-first-character.html)

Kevlar[_4_]

How do I test for the first character
 

OK, now I need to make this a little more complex. Instead of jus
comparing against One value: *Range("D18").Value = 1 * I would like t
use Range("D18").Value = 1 or 2 or 3.

Is that possible? How Would that be written?

If Target.Address = "$D$22" Then
If Range("D18").Value = 1 Then
If Mid((Range("D22")), 1, 1) = "A" Then
Checktool.Show
End If
End If
End I

--
Kevla
-----------------------------------------------------------------------
Kevlar's Profile: http://www.excelforum.com/member.php...nfo&userid=723
View this thread: http://www.excelforum.com/showthread.php?threadid=26522


Tom Ogilvy

How do I test for the first character
 
If it will only be an integer value then:

If range("D18") =1 and range("D18")<=3 then

or if it can be any value and you want specifically 1, 2 or 3

If range("D18") = 1 or _
range("D18") = 2 or _
range("D18") = 3 then

--
Regards,
Tom Ogilvy

"Kevlar" wrote in message
...

OK, now I need to make this a little more complex. Instead of just
comparing against One value: *Range("D18").Value = 1 * I would like to
use Range("D18").Value = 1 or 2 or 3.

Is that possible? How Would that be written?

If Target.Address = "$D$22" Then
If Range("D18").Value = 1 Then
If Mid((Range("D22")), 1, 1) = "A" Then
Checktool.Show
End If
End If
End If


--
Kevlar
------------------------------------------------------------------------
Kevlar's Profile:

http://www.excelforum.com/member.php...fo&userid=7231
View this thread: http://www.excelforum.com/showthread...hreadid=265222





All times are GMT +1. The time now is 03:31 PM.

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