Convert

  • Thread starter Thread starter Edgar
  • Start date Start date
E

Edgar

Hi

Thank you Frank and Bob for your help with the code below
to convert figures such as 1.6M and 0.25M into proper
numbers.

When ever i run the code below i get the
error 'Application defined or object defined error'

Does any know why this is happening?

TIA

Sub convert()

For x = 2 To Cells(Rows.Count, "L").End(xlUp).Row
Cells(i, "L").Value = Left(Cells(i, "L").Value, Len
(Cells(i, "L").Value) - 1) * 1000000
Next x

End Sub
 
Hi
some ideas:
1. the lines
Cells(i, "L").Value = Left(Cells(i, "L").Value, Len
(Cells(i, "L").Value) - 1) * 1000000
are actually ONE line

2. you may try if the above was not the cause of your error:
Cells(i, "L").Value = CDBL(Left(Cells(i, "L").Value, _
Len (Cells(i, "L").Value) - 1)) * 1000000
 
Hi Edgar,

Tut tut!

You are using the variable x as your loop counter, but then you reference
the cells via the variable i, not x.

If you used Option Explicit at the start of the module, you would not get
away with this. You can make this automatic by going into Tools>Options>Edit
and check the Require Variable Declaration box.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top