VBA: Parse preceding numbers from string
Posted
by
buttonsrtoys
on Super User
See other posts from Super User
or by buttonsrtoys
Published on 2014-06-02T20:40:36Z
Indexed on
2014/06/02
21:31 UTC
Read the original article
Hit count: 177
vba
I need to parse into two substrings a string that always starts with numeric text followed by alphnumeric text. The strings can vary a bit, but not too much. Below are examples of incoming format and the strings I need:
"00 10 50 Information to Bidders" ==> "00 10 50", "Information to Bidders"
"001050 Information to Bidders" ==> "001050", "Information to Bidders"
"00 10 50 - Information to Bidders" ==> "00 10 50", "Information to Bidders"
"001050 -- Information to Bidders" ==> "001050", "Information to Bidders"
I was hoping it would only be a half dozen lines of VBA, but my code is turning into a loop where I'm testing every character in the string to see where the changeover from numeric-only to non-numeric, then parsing the string based on the changeover location. Not a big deal, but messier than I was hoping for. Are there VBA functions that would eliminate the need to iterate through each string character?
© Super User or respective owner