In VBA, how do I remove everything after a specific character?

  • Thread starter Thread starter Lazer
  • Start date Start date
L

Lazer

Using String routines, how do I change the value
"7.00% " (String)
into "7.00" (Double)

i.e. to remove the "%" and everything after it?

Thanks,
Laze
 
Dim sStr as String
Dim dblVal as Double
sStr = "7.00% "
iloc = Instr(1,sStr,"%")
if iloc <> 0 then
dblVal = cdbl(Left(sStr,iloc-1))
Else
dblVal = 0
End if
 

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