Trim text before space I performed searches for this topic, but nothing exactly
ID: 3561541 • Letter: T
Question
Trim text before space
I performed searches for this topic, but nothing exactly matched what I'm trying to achieve in VBA.
I have filenames that all contain a part number followed by file text, such as 3992294 Process Sheet. All file names follow this format with the first space before Process acting as a delimiter.
I would like to assign only the part number to a variable called varPNumber. In this case the value of varPNumber would be 3992294, value before the first space, and trim off Process Sheet.
Explanation / Answer
*If you want a VBA statement:
varPNumber = Left(fileNameString, InStr(1,fileNameString, " ", vbBinaryCompare)-1)
I assume "varPNumber" is either Variant or String.
Or use below formula -
=LEFT(A1,SEARCH(" ",A1&" ")-1)
Hope this helps
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.