excel - VBA: Case sensitivity Options for MATCH in if-else statment -
so i've learnt here "option compare text" , "option compare binary" differentiate between case-sensitivity .match function.
right now, if-else statement shows i'm trying (albeit errors):
if dictionarydata.cells(4, 2).value = "yes" casesensitive = true networknamedict.comparemode = vbbinarycompare option compare binary else casesensitive = false networknamedict.comparemode = vbtextcompare option compare text end if
i need if else statement check if user wants compare case-sensitivity. "option" placed in there .match function work (found later in codes).
i understand "option" codes has typed @ top, need option stay dynamic due option being given users set in spreadsheet.
so question is, there way somehow case-sensitivity setting .match function in if-else statement?
this 2 options cannot used in 1 module, way call code 2 separated modules, 1 option compare text , another
1 option compare binary
.
approach use option compare binary
lcase
or ucase
comparing in example below:
option compare binary sub test() debug.print typename("yes") & " comparing" debug.print "yes" = "yes", "case sensitive" debug.print lcase("yes") = "yes", "not case sensitive" debug.print "yes" = ucase("yes"), "not case sensitive" debug.print ucase("yes") = ucase("yes"), "not case sensitive" debug.print typename(1.1) & " vs " & typename("1.1") debug.print 1.1 = "1.1", "not case sensitive" debug.print typename(1) & " vs " & typename("1") debug.print 1 = "1", "not case sensitive" debug.print typename(10000001) & " vs " & typename("10000001") debug.print 10000001 = "10000001", "not case sensitive" end sub
output in immediate window be
string comparing false case sensitive true not case sensitive true not case sensitive true not case sensitive double vs string true not case sensitive integer vs string true not case sensitive long vs string true not case sensitive
Comments
Post a Comment