• 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.

VBA HELP FOR DATA FORMATTING

Vickytayade18

New Member
Hi Amigos,
Good day!

I have code attached.
Code:
Sub HTS_TEMPLATE()

Dim x As Worksheet, y As Worksheet, LastRow&

Workbooks.Open ("C:Source.xlsm")
'source file

ActiveWorkbook.SaveAs Filename:="C:Output template.xls"
'to add a new file as output file

Set x = Workbooks("Source.xlsm").Worksheets("Sheet1")
Set y = ActiveWorkbook.Worksheets("Sheet1")


LastRow = x.Cells.SpecialCells(xlCellTypeLastCell).Row

x.Range("A1:A" & LastRow).Copy y.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
x.Range("B1:B" & LastRow).Copy y.Cells(Rows.Count, "E").End(xlUp).Offset(1, 0)
x.Range("H1:H" & LastRow).Copy y.Cells(Rows.Count, "H").End(xlUp).Offset(1, 0)
x.Range("I1:I" & LastRow).Copy y.Cells(Rows.Count, "I").End(xlUp).Offset(1, 0)

Application.CutCopyMode = False

End Sub

but with this code i not getting the formatting of header cells, which i want in attached output file format.( Color )
I want exact header as attached in Output file.

Please can anyone help me to modify this code ?
 

Attachments

Last edited:

Marc L

Excel Ninja
Attach the source workbook and the expected result workbook accordingly …​
If the source workbook is yet well formatted there is obviously nothin' to do !​
 

Marc L

Excel Ninja
For the formatting, the so obvious easy way is to save the workbook as a template Excel file​
in order when you need it you just have to open this template so the formatting is already done,​
no need any formatting code, you just have to copy the source data to this destination template workbook …​
 
Top