excel - Pull Site Code from Location Name (VBA) -
so have customer need specific code isolated name of each location. have following formula have been manually editing, wondering if there way have possibly count characters in cell , pull codes new cell.
example location name: mri-lenox hill radiology 150/14101
=right(a1,find("/",a1)-19)
the code format 0123/01234 (3 4 characters in front of slash , 5 after)
any in regard appreciated.
thanks,
justin hames
you can use regex find , extract code cell value. example:
with createobject("vbscript.regexp") .pattern = "\d{3,4}/\d{5}" if .test(range("a1")) range("b1") = .execute(range("a1"))(0) end if end
this extract code a1
, place b1
.
edit, respect comments:
to run on range of cells:
dim re set re = createobject("vbscript.regexp") re.pattern = "\d{3,4}/\d{5}" dim r range each r in range("a1:a100") if re.test(r) r.offset(0, 1) = re.execute(r)(0) next
Comments
Post a Comment