Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
i have 2 files, one create a txt file, and export a cell value with a date.
6-12-2006 The second file import txt file, and read the date field, and change 12-6-2006. How can resolve this question? Thank you in advance. -- Rui Santos |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If you use the wizard to open/import the text file, on the last screen you
can go field by field selecting basic formating options. You can select you date fields, and mark if you want them imported as MDY or DMY. Hope this helps, Miguel. "rmcsantos" wrote: i have 2 files, one create a txt file, and export a cell value with a date. 6-12-2006 The second file import txt file, and read the date field, and change 12-6-2006. How can resolve this question? Thank you in advance. -- Rui Santos |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I import the file, by an macro.
++++ Private Sub import_ficheiro_Click() Dim fs, a As Object Dim linha(23), linha_lida(23, 8), mystring, historico_caminho_destino, origem_caminho As String Dim timedate As Date Dim filetoopen As Variant Dim i, caracter, col_escrita, rwindex, colindex, linha_disp, linha_escr As Integer historico_caminho_destino = "\\anubis\Users\TimeSheet\history\" origem_caminho = "\\anubis\Users\TimeSheet" filetoopen = Application.GetOpenFilename("Text Files (*.txt), *.txt") If filetoopen = False Then Exit Sub End If Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.OpenTextFile(filetoopen, 1) For i = 1 To 23 linha(i) = a.readline Next i timedate = Left(Right(filetoopen, 14), 10) If linha(1) = "Ja Importado" Then MsgBox "Ficheiro já importado!" a.Close Exit Sub End If col_escrita = 1 linha_disp = Worksheets("BD_horas").Range("linha_disp").Value For i = 1 To 23 col_escrita = 1 For caracter = 1 To Len(linha(i)) mystring = Mid(linha(i), caracter, 1) If mystring < ";" Then linha_lida(i, 1) = linha_lida(i, 1) & mystring Else If col_escrita < 1 Then Else If linha_disp = 1 Or i = 1 Then linha_disp = linha_disp + 1 End If linha_escr = i + linha_disp If i = 3 Then linha_escr = linha_escr - i + 2 End If End If If col_escrita = 6 Then If linha_lida(i, 1) = "" Then Exit For Else linha_lida(i, 1) = linha_lida(i, 1) / 1 End If End If Worksheets("BD_Horas").Cells(linha_escr, col_escrita).Value = linha_lida(i, 1) linha_lida(i, 1) = "" col_escrita = col_escrita + 1 linha_disp = Worksheets("BD_horas").Range("linha_disp").Value End If Next caracter If linha_disp = 1 Or i = 1 Then Worksheets("BD_Horas").Cells(linha_escr, 8).Value = timedate Else Worksheets("BD_Horas").Cells(linha_escr - 1, 8).Value = timedate End If Next i a.Close Set fs = CreateObject("Scripting.FileSystemObject") fs.movefile filetoopen, historico_caminho_destino End Sub ++++ -- Rui Santos "Miguel Zapico" wrote: If you use the wizard to open/import the text file, on the last screen you can go field by field selecting basic formating options. You can select you date fields, and mark if you want them imported as MDY or DMY. Hope this helps, Miguel. "rmcsantos" wrote: i have 2 files, one create a txt file, and export a cell value with a date. 6-12-2006 The second file import txt file, and read the date field, and change 12-6-2006. How can resolve this question? Thank you in advance. -- Rui Santos |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
One solution can be to split the variable timedate in month, day and year,
and use them instead. Something like: dateday = left(timedate, 2) datemonth = mid(timedate, 4, 2) dateyear = right(timedate, 4) And then print them in the desired order instead of the timedate variable. Hope this helps, Miguel. "rmcsantos" wrote: I import the file, by an macro. ++++ Private Sub import_ficheiro_Click() Dim fs, a As Object Dim linha(23), linha_lida(23, 8), mystring, historico_caminho_destino, origem_caminho As String Dim timedate As Date Dim filetoopen As Variant Dim i, caracter, col_escrita, rwindex, colindex, linha_disp, linha_escr As Integer historico_caminho_destino = "\\anubis\Users\TimeSheet\history\" origem_caminho = "\\anubis\Users\TimeSheet" filetoopen = Application.GetOpenFilename("Text Files (*.txt), *.txt") If filetoopen = False Then Exit Sub End If Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.OpenTextFile(filetoopen, 1) For i = 1 To 23 linha(i) = a.readline Next i timedate = Left(Right(filetoopen, 14), 10) If linha(1) = "Ja Importado" Then MsgBox "Ficheiro já importado!" a.Close Exit Sub End If col_escrita = 1 linha_disp = Worksheets("BD_horas").Range("linha_disp").Value For i = 1 To 23 col_escrita = 1 For caracter = 1 To Len(linha(i)) mystring = Mid(linha(i), caracter, 1) If mystring < ";" Then linha_lida(i, 1) = linha_lida(i, 1) & mystring Else If col_escrita < 1 Then Else If linha_disp = 1 Or i = 1 Then linha_disp = linha_disp + 1 End If linha_escr = i + linha_disp If i = 3 Then linha_escr = linha_escr - i + 2 End If End If If col_escrita = 6 Then If linha_lida(i, 1) = "" Then Exit For Else linha_lida(i, 1) = linha_lida(i, 1) / 1 End If End If Worksheets("BD_Horas").Cells(linha_escr, col_escrita).Value = linha_lida(i, 1) linha_lida(i, 1) = "" col_escrita = col_escrita + 1 linha_disp = Worksheets("BD_horas").Range("linha_disp").Value End If Next caracter If linha_disp = 1 Or i = 1 Then Worksheets("BD_Horas").Cells(linha_escr, 8).Value = timedate Else Worksheets("BD_Horas").Cells(linha_escr - 1, 8).Value = timedate End If Next i a.Close Set fs = CreateObject("Scripting.FileSystemObject") fs.movefile filetoopen, historico_caminho_destino End Sub ++++ -- Rui Santos "Miguel Zapico" wrote: If you use the wizard to open/import the text file, on the last screen you can go field by field selecting basic formating options. You can select you date fields, and mark if you want them imported as MDY or DMY. Hope this helps, Miguel. "rmcsantos" wrote: i have 2 files, one create a txt file, and export a cell value with a date. 6-12-2006 The second file import txt file, and read the date field, and change 12-6-2006. How can resolve this question? Thank you in advance. -- Rui Santos |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
working out quarters (three-month periods) between two dates | Excel Worksheet Functions | |||
formula to add dates. | Excel Worksheet Functions | |||
Pre-1900 dates | Excel Discussion (Misc queries) | |||
How can I import dates from an Excel spreadsheet into a calendar . | Excel Worksheet Functions | |||
Formating Dates for production schedule | Excel Discussion (Misc queries) |