Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test to see if first letter is capitalized

Tags:

ms-word

vba

I was wondering if there is a way to test if the first letter in a table cell is capitalized without ripping the letter and comparing it to an array full of CHR codes or looping 26 instr() functions for every cell.

Basically, we have clients that send us tables in which the stub cell (far left) has part of the sentences on one line and then the rest on the line below, indented.

The issue is that I can't use the indents to test for these scenarios because other cells are indented for other reasons. I need to apply row shading depending on these scenarios and I'm having a hard time finding an efficient way to test for this.

This code returns 1

MsgBox (StrComp("This sentence continues", UCase("This sentence continues"), vbBinaryCompare))

This code returns 1 too

MsgBox (StrComp("this sentence continues", UCase("This sentence continues"), vbBinaryCompare))
like image 361
gNerb Avatar asked Oct 04 '22 00:10

gNerb


1 Answers

Assuming you already have the character stored in a string strFirst:

StrComp(strFirst, UCase(strFirst), vbBinaryCompare)

would return 0 if the letter is uppercase.

If you do not already have the first character from the text then you'll need to extract it using Left(string, 1).

like image 194
Andy G Avatar answered Oct 12 '22 12:10

Andy G