Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote