ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   case of the data (https://www.excelbanter.com/excel-programming/355376-case-data.html)

phil

case of the data
 
Is it possible to check the case of a string i.e. if its in lower or upper case

Robin Hammond[_2_]

case of the data
 
Phil,

Here's a code-friendly way:

Option Explicit
Option Private Module

Public Enum vbCase
vbMixedCase = 0
vbLowerCase = 1
vbUpperCase = 2
End Enum

Public Function GetCase(strTest As String) As vbCase
GetCase = -((LCase(strTest) = strTest) * vbLowerCase + _
(UCase(strTest) = strTest) * vbUpperCase)
End Function

Sub Test()
MsgBox GetCase("Robin") = vbUpperCase
MsgBox GetCase("Robin") = vbLowerCase
MsgBox GetCase("Robin") = vbMixedCase
End Sub

Robin Hammond
www.enhanceddatasystems.com

"phil" wrote in message
...
Is it possible to check the case of a string i.e. if its in lower or upper
case





All times are GMT +1. The time now is 02:24 PM.

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