Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Formatting as TEXT as opposed to scientific notation

In older version of XL, I had a solution that worked; essentially a
way to automate F2 and Enter via VBA. I now have XL 2000 and it
doesn't seem to work.

Here is what I am doing (before we get into the code to save us all
some time): I have a large CSV file that I open with XL. It opens
directly in XL as opposed to opening the conversion box as it would
with a delimited text file. Some of the columns should be text even
when the entire contents are numbers; they are displayed as 9.91001E
+14 instead of 991001000000000. If I copy this into Access the E+14
format is retained (not very useful). The column contains both text
and number (serial numbers) and the Access database has this column
formatted as Text (for when I paste it into Access).

Anyway, the long way to fix this is to select the column and format it
as text, and then select the first cell, press F2 and then Enter
(repeat a hundred times) to correct the formatting.

There must be an easier way.

Here is my current attempt (since the old method below stopped
working), but it doesn't work (seems to be an issue with the
sendkeys):

Dim Currentcell As Object, Nextcell As Object
Set Currentcell = ActiveSheet.Range("Q1")
Do While Not IsEmpty(Currentcell)
Set Nextcell = Currentcell.Offset(1, 0)
Currentcell.Select
Selection.NumberFormat = "@"
ActiveCell.FormulaR1C1 = Currentcell.Value
Selection.NumberFormat = "@"
SendKeys "{F2}", Wait
SendKeys "{enter}", Wait
Set Currentcell = Nextcell
Loop

The old method was to have this section:
Selection.NumberFormat = "@"
ActiveCell.FormulaR1C1 = Currentcell.Value
Selection.NumberFormat = "@"
SendKeys "{F2}", Wait
SendKeys "{enter}", Wait

Read as:
Selection.NumberFormat = "@"
Currentcell = Currentcell.Value
Selection.NumberFormat = "@"

This used to work. Essentially is said the current cell is equal to
the current cell value.

The number of rows always changes for my data and there are multiple
columns that I will need to run this on. Also, there are sometimes
blanks (the above code works when I do not have blanks, so I did
forced it to work by entering in data just to try to get the rest of
the code to work).

I did a lot of searching on this issue and did see that the sendkeys
method is not recommended, but I couldn't figure out another way.

Thanks in advance.
Steve

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
Scientific Notation - I want excel to read it as a text not a numb Jim McC Excel Discussion (Misc queries) 1 February 19th 07 08:08 PM
Number Formatting/Scientific notation Patrice Excel Discussion (Misc queries) 1 January 19th 07 08:55 PM
Scientific notation in text cells miles Excel Discussion (Misc queries) 3 December 7th 06 10:59 PM
change scientific notation (exponential) back to text GEORGIA Excel Discussion (Misc queries) 1 April 6th 06 04:21 PM
Using scientific notation in TEXT() function boopathi Excel Worksheet Functions 1 October 10th 05 08:23 PM


All times are GMT +1. The time now is 04:55 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"