Excel macro to extract text from a cell
Posted on 2006-06-07
Hello Experts! Can someone help me extract some text from a cell i VB?!
For instance, I have a cell with this sort of content (ignore the quotation marks): "ALC: IECP SP06 C (67)" or it can contain something like: "ALC: AIEP (266)", or even this "ALC: Agent Certs (6)"
Basically, the cell data's lenght changes, however, what i am interested in is the NUMBER part of any of the above examples. I would like to be able to extract the number value and assign it to a variable to i can later add these values up. For instance, how can i extract 67 from a cell that contains this text: "ALC: IECP SP06 C (67)" or 266 from a cell with this data in it: "ALC: AIEP (266)" etc? Do i need to use Regular Expression? Again, the cells length differs, only numbers are consistently surrounded by two brackets (). So, the numebr i need extracted and assigned to variable is always surrounded by ( and ).
Thanks a lot for any help!!!