This is a continuation of a project I'm working on and had help on:
http://www.mrexcel.com/forum/showthread.php?t=315241
Using my Old code that I am trying to modify with jindon's suggestions from the above link:
Old code:
Gives me a Text file as below:
With this modification to the above code using jindon's lead:
I come up with this Text file:
As you can see Col C & K come up with date serial numbers and Col H comes up with 13 didgits to the right of the decimal.
I am running both macros from the same Workbook (for testing purposes). Cols C & K are formatted as Custom > m/d, and Col H is formated as Number > 2 decimal places.
I am lost on how to make second macro produce the results that the first one did in the Text file.
Harry
http://www.mrexcel.com/forum/showthread.php?t=315241
Using my Old code that I am trying to modify with jindon's suggestions from the above link:
Old code:
Code:
Sub CopyToNewBook()
Dim Response As Integer
On Error Resume Next
Response = MsgBox(Prompt:="This procedure will export the payroll SUMMARY" & vbCr & _
"into a Tab Delimited Text File and save it to C:\Payroll" & vbCr & _
" PROCEED", Buttons:=vbQuestion + vbYesNo, Title:=" FINAL STEP")
If Response = vbNo Then
Exit Sub
End If
Application.ScreenUpdating = False
'//Copy the SUMMARY sheet to a new book (Text tab delimited).
Sheets("SUMMARY").Copy
'//Identify the path you wish to save to here.
MkDir "C:\Payroll"
ChDir "C:\Payroll"
'//Save the export sheet as a new workbook named "Payroll"
'//and the date that resides in the PAYCALC sheet cell B3
'//Copy will be saved as tab delimited text.
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "Payroll" & " " & _
Format(Sheet1.Range("C4").Value, "mmm,dd,yy") & ".txt", _
FileFormat:=xlText, CreateBackup:=False
'//Close the copy and return to the original.
ActiveWorkbook.Close
Application.DisplayAlerts = True
MsgBox Prompt:="Export of payroll information to a text file complete" & vbCr & _
"The file may be found on your C drive in a folder named Payroll", _
Title:=" PROCEDURE SUCCESSFUL"
End Sub
Excel Workbook | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | |||
1 | LBZVB010.55.ST30 | LS0145 | 6/7 | 7 | 1 | * | 468 | 72.57 | STUCCO | 5022 | 5/28 | ||
2 | LBZVB010.55.ST30 | LS0140 | 6/7 | 7 | 1 | * | 650 | 100.79 | STUCCO | 5022 | 5/28 | ||
3 | LBZVB010.55.ST30 | LS0372 | 6/7 | 7 | 1 | * | 600 | 93.04 | STUCCO | 5022 | 5/28 | ||
4 | LBZVB010.55.ST30 | LS0373 | 6/7 | 7 | 1 | * | 400 | 62.03 | STUCCO | 5022 | 5/28 | ||
Sheet1 |
With this modification to the above code using jindon's lead:
Code:
Sub CopyToTextFile()
Dim Response As Integer
On Error Resume Next
Response = MsgBox(Prompt:="This procedure will export the payroll SUMMARY" & vbCr & _
"into a Tab Delimited Text File and save it to your" & vbCr & "! DESKTOP ! with a Date and Time Stamp To The Second" & vbCr & _
" " & vbCr & " PROCEED", Buttons:=vbQuestion + vbYesNo, Title:=" FINAL STEP")
If Response = vbNo Then
Exit Sub
End If
Application.ScreenUpdating = False
'//Copy the SUMMARY sheet to a new book (Text tab delimited).
fn = CreateObject("WScript.Shell").SpecialFolders("Desktop") & _
"\Payroll Export(" & Format$(Now, "mmddyy-hh-mm-ss") & ").txt"
With Sheets("SUMMARY")
For Each r In .Range("K1", .Range("K" & Rows.Count).End(xlUp))
If r.Value <> 0 Then txt = txt & vbCrLf & Join(Evaluate("transpose(transpose(" & _
r.Offset(, -10).Resize(, 11).Address & "))"), vbTab)
Next
End With
Open fn For Output As #1
Print #1, Mid$(txt, Len(vbCrLf) + 1)
Close #1
Range("A1").Select
Application.ScreenUpdating = True
SplashForm.Show
MsgBox Prompt:="Export of payroll information to a text file complete" & vbCr & _
"The file may be found on your DESKTOP with a Time Stamp", _
Title:=" PROCEDURE SUCCESSFUL"
End Sub
I come up with this Text file:
Excel Workbook | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | |||
8 | LBZVB010.55.ST30 | LS0145 | 39605 | 7 | 1 | * | 468 | 72.5696202531646 | STUCCO | 5022 | 39596 | ||
9 | LBZVB010.55.ST30 | LS0140 | 39605 | 7 | 1 | * | 650 | 100.7911392405060 | STUCCO | 5022 | 39596 | ||
10 | LBZVB010.55.ST30 | LS0372 | 39605 | 7 | 1 | * | 600 | 93.0379746835443 | STUCCO | 5022 | 39596 | ||
11 | LBZVB010.55.ST30 | LS0373 | 39605 | 7 | 1 | * | 400 | 62.0253164556962 | STUCCO | 5022 | 39596 | ||
Sheet1 |
As you can see Col C & K come up with date serial numbers and Col H comes up with 13 didgits to the right of the decimal.
I am running both macros from the same Workbook (for testing purposes). Cols C & K are formatted as Custom > m/d, and Col H is formated as Number > 2 decimal places.
I am lost on how to make second macro produce the results that the first one did in the Text file.
Harry