Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello All,
The macro below provided by Mr. Rick Rothstein works perfect. It export the worksheet to a text file. I wish to change it further to suit to my needs. I use excel 2003 (Windows XP) Sub WriteDataOut() Dim X As Long Dim FF As Long Dim LastRow As Long Dim Dte As String Dim Record As String Dim TotalFile As String Dim FileNameAndPath As String FileNameAndPath = "c:\Dir1\Dir2\etc\FileName.txt" With Worksheets("Sheet1") LastRow = .Cells(Rows.Count, "C").End(xlUp).Row For X = 10 To LastRow Record = Space$(66) Mid$(Record, 1) = .Cells(X, "C").Value Mid$(Record, 10) = Format$(.Cells(X, "F").Value, "0000000000") Dte = .Cells(X, "H").Value Mid$(Record, 20) = Right$(Dte, 4) & Mid$(Dte, 4, 2) & Left$(Dte, 2) Dte = .Cells(X, "H").Value Mid$(Record, 28) = Right$(Dte, 4) & Mid$(Dte, 4, 2) & Left$(Dte, 2) Mid$(Record, 36) = Format$(100 * Abs(.Cells(X, "K").Value), _ "000000000000000") Mid$(Record, 51) = .Cells(X, "L").Value Mid$(Record, 56) = .Cells(X, "Q").Value TotalFile = TotalFile & vbCrLf & Record Next FF = FreeFile Open FileNameAndPath For Output As #FF Print #FF, TotalFile Close #FF End With End Sub Changes required: The file should be saved in the given Folder Path using the Cell Value (E5) with date and time stamped e.g if cell value (E5) in the excel file is 1234 then the file should be saved as "1234 (date) (time)".txt . If the value in E5 is 3456 then it should be saved as "3456 (date) (time).txt" At present it saves as filename.txt and it overwirtes the previous version too. I need to have all the old files with date and time stamped for future references using the Cell Value in E5. Can someone help me please? Thanks in advance Rushna |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - CSV file, trying to save a date as text, reverts back to d | Excel Worksheet Functions | |||
customer date time save file | Excel Discussion (Misc queries) | |||
Save File with Date and Time Stamp | Excel Programming | |||
Macro to save Excel file with date and time in the file name? | Excel Programming | |||
Date stamped comment box | Excel Programming |