I am trying to take the value of a text box on a user form and assign it to a string variable, then insert hyphens into that string variable using the String class’s Insert method. Every time I run this code, I get an error ‘Invalid Qualifier” with AcctUnitString highlighted.
Dim AcctUnitString As String
AcctUnitString = AcctUnit.Text
AcctUnitString = AcctUnitString.Insert(2, "-")
Debug.Print (AcctUnitString)
AcctUnit is the name of the text field on the user form. Any ideas what might be causing this error, or a better way of doing what I’m trying to do?
The user will enter a 13 digit code in the text box (example 9200030015001) and I want to format it thusly: 92-0003-001-5001. Any help is greatly appreciated. Thanks!
I don’t know of a built in Excel function to do what you are looking for.
http://www.vbforums.com/showthread.php?141943-Insert-string-within-another-string-at-specific-position