#NAME? Error Fix?

M

Martin Just

Hi all. I'm importing a bunch of data from a .csv file. The host
application is not able to delimit the Customer Name field correctly, so for
some record types, I get values that look like:

=-- John Smith

Excel interprets this as a bad formula and returns #NAME? in the cell. I'm
trying to remove the leading characters using

If Left(ActiveCell.Value, 1) = "=" Then
ActiveCell.Value = Right(ActiveCell.Value,
Len(ActiveCell.Value) - 5)
End If

but get a Type Mismatch error. Any ideas how to tell Excel they are not
formulas?

Thanks much!
 
D

Don Guillett

Let us know if this works.

Sub cleanitup()
For Each c In Selection
x = c.Formula
If c.HasFormula Then c.Value = Right(x, Len(x) - 4)
Next
End Sub
 
M

Martin Just

Perfect! Thanks so much!




Don Guillett said:
Let us know if this works.

Sub cleanitup()
For Each c In Selection
x = c.Formula
If c.HasFormula Then c.Value = Right(x, Len(x) - 4)
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

Similar Threads


Top