I am reading data from an text file, and I am trying to format it to match a Defined Name for a cell. The defined name is 89NL_10ETH_A and the string is 89NL 10ETH A but with a bunch of spaces after it. I used Replace() to convert spaces into "_", but all of the spaces at the end are converted to underscores. How can I trim the spaces off of a fixed length, mind you Trim() did not work because of the fixed length?
This is how I am currently doing it
getProduct = Replace(Replace(Mid(Ln, 40, 24), "#", ""), "%", "")
Application.TrimI believe works for VBA. Instead using the replace, after the Trim you could useSplit(STR, " ")and finallyJoin(arrSTR, "_")Trim()works. Use it first, before replacing the remaining spaces.Midlength too long and it was picking up a period from the next column that i wasn't seeing, and why it looked like myTrimwasn't working.