|
-
Dec 20th, 2020, 11:16 AM
#10
Re: Formating a cell after successful validation
 Originally Posted by Kardacian
I was not able to use the cell.Value.ToTitle statement. It repeatedly causes an exception error. I did add the extension code as outlined above. I tried a few different ways and it compiles, but I must be implementing it wrong. so for now I am using the StrConv
cell.Value = cell.Value.ToTitle() 'crashes
cell.Value = StrConv(cell.Value, vbPropperCase) 'works
A crash is an unhandled exception. You should do some debugging and examine the exception to see why it is being thrown and then you can address it. The fact that cell.Value.ToTitle() compiles suggests that you have Option Strict Off, so you should turn that On straight away. That would force you to cast the Value property, which is type Object, as type String. My suspicion is that you are allowing the cell to remain empty, in which case the Value would be Nothing and that, I think, would throw an ArgumentNullException when calling TextInfo.ToTitleCase.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|