1

Given a string, which may end with a number within braces, how can I extract as separate variables: (1) the number; (2) the string, sans the braces and number?

String examples: filename.docx file name.pdf{10}

user2319146
  • 371
  • 1
  • 11
  • 1
    remove the end brace with replace and split on the opening brace. – Scott Craner Jan 14 '21 at 23:26
  • You might consider providing some samples of the types of strings you're working with. Seems like a good job for regular expressions https://stackoverflow.com/questions/22542834/how-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops – Tim Williams Jan 14 '21 at 23:40

1 Answers1

1

Like this, for example:

Filename = "filename.docx" 
Filename = "file name.pdf{10}"

FileNumber = Val(Mid(Filename, InStr(Filename, "{") + 1))
FileText = Split(Filename, "{")(0)
Gustav
  • 53,498
  • 7
  • 29
  • 55