adding columns and headers with a macro

tabspace

New Member
Joined
Oct 23, 2017
Messages
16
I would like to add a button that can create 5 columns at the end right of the table. Each new set should have 2 rows of headers, the first one, on row 1 should be a merged cell of 5 cells that says TITLE. The second row should have the following headers (one for each cell): M, T, W, T, F (for the days of the week)

Could anybody help with this?

Thanks!

Jim
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I don't believe that additional columns added to a table can be "MERGED", so the below code Adds 5 columns to the right of the existing table
and labels each column Mon - Fri. Hope this helps (getting you started)...

Code:
Sub Foo()
Dim Ncol As Long
Application.EnableEvents = False
Ncol = Cells(1, Columns.Count).End(xlToLeft).Column + 1
Range(Cells(1, Ncol), Cells(1, Ncol + 4)) = Array("Mon", "Tue", "Wed", "Thu", "Fri")
Application.EnableEvents = True
End Sub
 
Upvote 0
Hi Jim,

Thanks again. I have a question though. How can I make that be on row 2? or 3? or whatever row I want it to be?

THanks!
 
Upvote 0
Note my refetence (s) to cells (1,
To change to row 2 modify code to
cells (2,
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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