Double quote entry in textbox causing runtime error 1004

TheWordsmith

New Member
Joined
Aug 1, 2017
Messages
3
Error message: Run-time error 1004: Application-defined or object-defined error.

Context: I have a userform with a textbox that I am using to enter data which is then written to a cell in an excel sheet. The problem I'm having is that when a quotation mark is entered into the text box it causes the above error on the line where the .value of the cell is set equal to a string containing the textbox entry. Note that this only crashes with a double quote, it works for other strings and even for single quotes.

Abbreviated version of the string that caused the crash: ... 1" charge line ...

Something interesting to note is that if I copy+paste into the textbox it doesn't crash, but if I type it in it does.

Any help would be much appreciated!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Update: I discovered why copy+paste does not cause a crash. Copying from MS Word copied Word's quote mark which uses ASCII code 148 instead of the ASCII code 34 character that is used when typing in the Userform textbox.

However I'm still not sure how to make this work when typing. I would rather not require users to copy+paste from Word every time :laugh:
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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