Excel VBA - Force Uppercase Error when Contents Deleted -
i'm trying force cell take uppercase value, works, using code below.
if intersect(target, range("b9", "f10")) nothing exit sub application.enableevents = false activesheet.unprotect password:="" target = ucase(target) application.enableevents = true activesheet.protect password:=""
however, when contents of cell deleted (which may required) receive following error "run-time error '13': type mismatch"
if can shed light on this, that'd great!
target range, not string (assuming using worksheet_change event).
the should multiple cells changing @ once, not empty cells.
when have 1 single cell, fine, because value of target evaluate target.value generaly castable string. when change more 1 cell @ once, target.value return array, wich not castable string.
so must change each cell @ time:
dim cell range, cells range set cells=intersect(target, range("b9", "f10")) if cells nothing exit sub application.enableevents = false activesheet.unprotect password:="" each cell in cells.cells cell.value = ucase(cell.value) next application.enableevents = true activesheet.protect password:=""
Comments
Post a Comment