• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to Add Header Footer

dingdang

Member
Hi,


I have recorded macro which convert 8 column data in to text file ( save as Report.txt ) in folder like :


6206451560017465400000000110000002000000600400005

6206451460017465400000000110000002500000600400005

6224070760001200100000000110000000554400600400005

6206466660001407500000000250000005000000600400005

6264541460024000200000000250000002405000600400005

6200054160016501000000000110000005000000600400005

6201554160001400200000000250000002056100600400005


I just want to add Header and Footer in to file , can u pls help me to add code in macro . required below output file from macro.


in Header line :64( code no for header )+date in ddmmyyyy format and at last column 600400000

in Footer line : 65 ( code no for footer )+ count of data + ( from right side )13 digit total of amount+600400000

Red colour is Amount column in data


6402042012 600400000

6206451560017465400000000110000002000000600400005

6206451460017465400000000110000002500000600400005

6224070760001200100000000110000000554400600400005

6206466660001407500000000250000005000000600400005

6264541460024000200000000250000002405000600400005

6200054160016501000000000110000005000000600400005

6201554160001400200000000250000002056100600400005

6265716160016406600000000110000001650100600400005

6262701260017440200000000250000004104100600400005

6255526160017467600000000250000000656000600400005

65000272 0025925700600400000


Attached sample required output file for your ref. Pls help


https://dl.dropbox.com/u/66400357/Report.txt
 
Hi, dingdang!

Would you please consider uploading the workbook or posting the code of the macro? Thank you.

Regards!
 
Sir,


code as below , count and amount Total of column "E" required in footer


in Header line :64( code no for header )+date in ddmmyyyy format and at last column 600400000

in Footer line : 65 ( code no for footer )+ count of data + ( from right side )13 digit total of amount+600400000

Red colour is Amount column in data


Application.CutCopyMode = False

ActiveCell.FormulaR1C1 = "32"

Range("A1").Select

Selection.AutoFill Destination:=Range("A1:A16")

Range("A1:A16").Select

Columns("E:E").Select

Selection.NumberFormat = "0000000000000"

Columns("F:F").Select

Selection.NumberFormat = "000000"

Range("A1").Select

ChDir "C:Documents and SettingsAdministratorDesktop"

ActiveWorkbook.SaveAs Filename:= _

"C:Documents and SettingsAdministratorDesktopReport1.txt", FileFormat:= _

xlText, CreateBackup:=False

End Sub
 
Back
Top