Add headings to columns in a worksheet through vba

sukyb1

Board Regular
Joined
Mar 27, 2009
Messages
153
I have the following code. In the "Master" worksheet I want to add columns headings from cells A1 to Z1
how can i do this through vba?

Sub Do_it()
Dim ws As Worksheet, rs As Worksheet
Set ws = Worksheets("Master")
Set rs = Worksheets("Point Estimate Complete")
GoSub Combine
Set rs = Worksheets("Estimates Validated")
GoSub Combine
Set rs = Worksheets("Estimate In Progress")
GoSub Combine
Set rs = Worksheets("Other Status")
GoSub Combine
Exit Sub
Combine:
lr = rs.Range("A65536").End(xlUp).Row - 3
lr2 = ws.Range("A65536").End(xlUp).Row + 1

rs.Range("A3:Z" & lr).Copy

ws.Range("A" & lr2).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

lr3 = ws.Range("A65536").End(xlUp).Row

ws.Range(ws.Cells(lr2, "AA"), ws.Cells(lr3, "AA")) = rs.Name 'd

Return

End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Code:
Worksheets("Master").Range("A1:Z1").Value = _
    Array("Heading A", "Heading B", "Heading C", _
            "Heading D", ..., "Heading Z")
 
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top