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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Code:
Worksheets("Master").Range("A1:Z1").Value = _
    Array("Heading A", "Heading B", "Heading C", _
            "Heading D", ..., "Heading Z")
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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