ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Extract 2, 3, 4 or 5-digit number from string (https://www.excelbanter.com/excel-programming/331057-extract-2-3-4-5-digit-number-string.html)

Jim[_55_]

Extract 2, 3, 4 or 5-digit number from string
 
I have a list of URLs where some contain the parameter "categoryid="
with either a 2, 3, 4, or 5 digit number. I need to extract that
number, as an integer, into a neighboring column. I need a routine or
function to help with this - something along the line of making the mid
function smart enough to recognize numbers and adjust the length value
so it only takes the numbers. And if it doesn't find "categoryid",
then leave the cell blank.

TIA,
Jim


Tom Ogilvy

Extract 2, 3, 4 or 5-digit number from string
 
Assuming the URL's are in Column A beginning in A1 put in this formula using
Ctrl+Shift +Enter to enter it rather than just enter since it is an array
formula. Then drag fill down the column.

=IF(ISNUMBER(FIND("categoryid=",A1)),MAX(IF(ISNUMB ER((MID(A1,FIND("categoryi
d=",A1)+11,{1,2,3,4,5}))*1),(MID(A1,FIND("category id=",A1)+11,{1,2,3,4,5}))*
1,"")),"")



--
Regards,
Tom Ogilvy

"Jim" wrote in message
ups.com...
I have a list of URLs where some contain the parameter "categoryid="
with either a 2, 3, 4, or 5 digit number. I need to extract that
number, as an integer, into a neighboring column. I need a routine or
function to help with this - something along the line of making the mid
function smart enough to recognize numbers and adjust the length value
so it only takes the numbers. And if it doesn't find "categoryid",
then leave the cell blank.

TIA,
Jim




Jim[_55_]

Extract 2, 3, 4 or 5-digit number from string
 
Many thank, Tom.

Jim



All times are GMT +1. The time now is 04:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com