Check letter capitalisations

abdulhaque

Board Regular
Joined
Dec 2, 2015
Messages
63
Hi all,

Is it possible to conduct the following checks in the order listed?

1. Is the first character a number or letter, if it's a letter, is it capitalised? If it's not capitalised, it needs review.
2. Is any character after any space capitalised and the following character not capitalised nor it's a symbol? Needs review

Essentially I need the results to look like the following example. The red font means the cell needs review, whereas the blue font means its ok.

2ahf5w6.png
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
By your rules, "A - Alert" should be "Review". Also, you'll need a UDF to do this I think.


Book1
AB
1StrongCorrect
2Doppler onlyCorrect
31Correct
44-6 stepsCorrect
5PCA pumpCorrect
6possible delirium +/- cognitive impairmentReview
7Not ApplicableReview
8Form-mashed €Correct
9Nil By MouthReview
10Grade 1 (Very mildly thick)Correct
111L fluid restrictionCorrect
12A - AlertReview
132/3 StoryReview
14Advised To Attend A&EReview
Sheet1
Cell Formulas
RangeFormula
B1=ReviewText($A1)


Code:
Public Function ReviewText(testString As String) As String

Dim words As Variant
Dim word As Long

If Left(testString, 1) >= "a" And Left(testString, 1) <= "z" Then
    ReviewText = "Review"
    Exit Function
End If

words = Split(testString, " ")
For word = 1 To UBound(words)
    If Len(words(word)) > 1 Then
        If Left(words(word), 1) >= "A" And Left(words(word), 1) <= "Z" _
        And Mid(words(word), 2, 1) >= "a" And Mid(words(word), 2, 1) <= "z" Then
            ReviewText = "Review"
            Exit Function
        End If
    End If
Next word

ReviewText = "Correct"

End Function

WBD
 
Upvote 0
By your rules, "A - Alert" should be "Review". Also, you'll need a UDF to do this I think.

Code:
Public Function ReviewText(testString As String) As String

Dim words As Variant
Dim word As Long

If Left(testString, 1) >= "a" And Left(testString, 1) <= "z" Then
    ReviewText = "Review"
    Exit Function
End If

words = Split(testString, " ")
For word = 1 To UBound(words)
    If Len(words(word)) > 1 Then
        If Left(words(word), 1) >= "A" And Left(words(word), 1) <= "Z" _
        And Mid(words(word), 2, 1) >= "a" And Mid(words(word), 2, 1) <= "z" Then
            ReviewText = "Review"
            Exit Function
        End If
    End If
Next word

ReviewText = "Correct"

End Function

WBD

Thanks a lot. The power of VBA works wonders.
 
Upvote 0
Thanks a lot. The power of VBA works wonders.
I believe this slightly more compact UDF will also work for you...
Code:
Function ReviewText(ByVal S As String) As String
  If S Like "[!A-Z0-9]*" Or S Like "?* [A-Z][a-z]*" Then
    ReviewText = "Review"
  Else
    ReviewText = "Correct"
  End If
End Function
 
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,282
Members
449,094
Latest member
GoToLeep

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top