MID in VBA

J

Jeff

Hello,

I need help to design a VBA formula that would return a date using the
function MID for the following text in row A11 "DANN010104" to become
"01-jan-04" in Row B11. Also, I'd like to formula to run in all rows in
Column A when there's a text.
Jeff
 
F

Frank Kabel

Hi
try the following macro

sub foo()
dim lastrow as long
dim rowindex as long
dim slen as integer
with activesheet
lastrow=.Cells(Rows.Count, 1).End(xlUp).Row
for rowindex=1 to lastrow
with .cells(rowindex,1).
if .value<>"" then
slen=len(.value)
.value=dateserial("20" &
right(.value,2),mid(.value,slen-3,2),mid(.value,slen-5,2))
end if
end with
next
end sub
 
Top