none
C#: Convert Cell to Date RRS feed

  • Question

  • Hello,

    I want to convert a cell/range-content to date-format. Before conversion the content is in "Text"-Format.

    • If I use Excel-Userinterface via Menu "Data -> "Text To Columns"       it works perfectly.

    • If I use this code:
      range.NumberFormat = "dd/MM/yyy";
      range.TextToColumns();

      then nothing happens.

    I seareched the I-Net a lot, but so far: no success

    Wednesday, March 27, 2019 4:38 PM

All replies

  • It's me again.

    I did not find a solution, but I found a workaround.

    I have written a Macro which I store inside Excel, then I call it.

    I iterate over all cells and inside I have this "Key-Line" which converts to real Date-Format

    Cell.Value2 = CDate(Cell.Text)
    

    A terrible solution, but it works at least



    • Edited by Somigur Wednesday, March 27, 2019 6:43 PM
    Wednesday, March 27, 2019 6:41 PM