If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > VBA Macro: problems in changing format

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-18-05, 03:01
ioclio ioclio is offline
Registered User
 
Join Date: Jun 2004
Location: Italy
Posts: 15
Angry VBA Macro: problems in changing format

Hi,
I'm currently having big problems with this.

- I open a text file, f.i. "mytext.txt", containing numbers. A typical line in the text file may be: "290,25";"299,92";"294,46". To do that I use:

Code:
Workbooks.OpenText Filename:="mytext.txt", StartRow:=1, TextQualifier:="xlDoubleQuote", DataType:="xlDelimited", Semicolon:=True, FieldInfo:=etc. etc.
- Now: I would like to transform numbers which are in text format in numeric format as I want to execute operations on them.
To do that I use:

Code:
Range("D1").Select
Selection.NumberFormat = "0,00"
ActiveCell.FormulaR1C1 = "0"
Range("D1").Copy
Range("A1:C1").PasteSpecial Paste:=xlPasteAll, Operation:=xlPasteSpecialOperationSubtract
but nothing changes, number remains in text format.
The strange thing is that executing the same operations out of a macro, the formats change! The previous code was infact obtained recording a macro and executing the normal excel operations on the range I want to transform.

Where am I wrong?
Thanks for your help.
Reply With Quote
  #2 (permalink)  
Old 01-20-05, 05:01
JanTheDane JanTheDane is offline
Registered User
 
Join Date: Jan 2005
Posts: 1
I've got the same prob.

When receiving a data file from UK, the decimal separator is a "." I'm using "," as separator. I use application.Replace but have to enter the cell in order to make the change effective?

The problem does not appear whilst using the replace function without VBA?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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