In VBA, add a decimal after the 5th digit of a number.

I have a number, like this, "394154616203704" and I need to place a decimal after the 5th digit, like this: 39415.4616203704
There can be a varying amount of digits after the decimal.   I need to do this in VBA to a number that is in a text box.

I have been playing with the Format function but can't seem to get it right. I greatly appreciate your help.

Thank you!
JA67

Open in new window

JA67Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
try  using the left and mid function, do you have to save this as number or text

left("394154616203704",5)&"."&mid("394154616203704",6)

or
left(me.textname,5)&"."&mid(me.textname,6)
0
 
Rey Obrero (Capricorn1)Commented:
or
cdbl(left(me.textname,5)&"."&mid(me.textname,6))
0
 
JA67Author Commented:
Thank you!  That works great! I am going to store the this as a number.
0
 
JA67Author Commented:
I have received excellent help from capricorn1 on many occassions!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.