MID in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top