excel vba - Trim Cell Contents to Certain Lenght with Scientific Numbers -


i have column of numbers need keep numbers limit length 20 characters.

sub casecheck()  dim mystring string dim newstring string dim char variant  'replace special characters nothing const specialcharacters string = "!,.,#,$,%,^,&,-,(,),{,[,],},/,\, "  = 2 trans  mystring = worksheets("data input").cells(i, 10).value newstring = mystring each char in split(specialcharacters, ",") newstring = replace(newstring, char, "") worksheets("expertpay feed").cells(i, 3).value = newstring worksheets("expertpay feed").cells(i, 3).numberformat = "0" next next  'trim length down 20 characters  = 2 trans worksheets("expertpay feed").cells(i, 3).value = left(worksheets("expertpay feed").cells(i, 3).value, 20) next   end sub 

my code works well, except when have numbers long. example:

this original number: 1.31137e+17 turns 13113690920150400000000000000000 , can't seem trim off zeroes!

try function:

function trimtrailingzeroes(bignumber string) string     dim integer     = len(bignumber) 1 step -1         if mid(bignumber, i, 1) <> "0"             trimtrailingzeroes = left(bignumber, i)             exit function         end if     next     trimtrailingzeroes = bignumber end function 

sometimes in can easy way out treating numbers text.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -