Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Fixing Error 2029 (#NAME?)

Here is my problem, I am importing a CSV file that somewhere along the line got messed up. An alpha field managed to get a leading hyphen (ex: "-John Q Public"). When it gets imported, excel thinks it is a numeric value add an equals sign in front. Now the cell is an error (#NAME?). How can I programmatically fix the cell by removing the "=-"? I can identify it using IsError(rngCel.value), but I can not seem to modify the contents. Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default Fixing Error 2029 (#NAME?)

"pb" wrote:
Here is my problem, I am importing a CSV file that somewhere
along the line got messed up. An alpha field managed to get
a leading hyphen (ex: "-John Q Public"). When it gets imported,
excel thinks it is a numeric value add an equals sign in front.
Now the cell is an error (#NAME?). How can I programmatically
fix the cell by removing the "=-"? I can identify it using
IsError(rngCel.value), but I can not seem to modify the contents.


It sounds like you are __opening__ the CSV file, not __importing__ it per
se.

One suggestion: use the External Data Import Text wizard to truly
__import__ the file. Then in the final menu, you might be able to select
type Text for the entire column that contains names.

That would avoid the problem altogether. I cannot give you step-by-step
instructions because you neglected to say what version of Excel you are
using.

If the Import Text wizard does not work for you (for example, you cannot
make the entire column Text because it contains a mix of data), then you can
use the following paradigm:

If IsError(rngCel.Value) Then
rngCel.Value = "'" & Mid(rngCel.Formula, 2)
End If

In case the string constant is difficult to read in your font, that is
double-quote single-quote (aka apostrophe) double-quote.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Fixing Error 2029 (#NAME?)

joeu2004,

Thanks for the help. I forgot to check rngCol.Formula.
All I needed was: rngCol.Value = Mid(rngCol.Formula, 3)

You are right, I am opening the CSV then fix the data before saving it. I have to do it this way because there are fields with imbeded CR, LF and Tab characters in them that really mess it up when I import it.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 2029. How do I fix this error Ayo Excel Programming 4 November 10th 09 05:47 PM
Problem sorting by date after 2029 on Excel 2003 wtchywmn9 Excel Discussion (Misc queries) 1 October 29th 09 05:43 PM
Fixing a vlookup macro that returns #N/A error Grosvenor Excel Discussion (Misc queries) 1 February 8th 06 12:23 PM
Error 2029 using Find XL 97 jonnyexcelneill Excel Programming 1 November 25th 04 06:57 PM


All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"