Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004

    Angry Unanswered: VBA Macro: problems in changing format

    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:

    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:

    Selection.NumberFormat = "0,00"
    ActiveCell.FormulaR1C1 = "0"
    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.

  2. #2
    Join Date
    Jan 2005

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts