Insert columns into worksheet (VBA?)

lawi227

Board Regular
Joined
Mar 17, 2016
Messages
123
I have a workbook that I am creating that does an analysis. The analysis can be done for 1 or 2 companies.

Rather than making changes manually (like adding columns to a worksheet), I would like to be able to type "1" or "2" in to a cell and have a code linked to that cell that will do the changes I need. This text box is located in cell E3 on a tab called "Instructions".

The first change I need is to add two columns to a worksheet.

When "2" is typed in to E3 on the "Instructions" tab, I need to duplicate columns I, J, K, L and paste them right after column L. Note: there is information in column M:Q. Below is an example of what my worksheet looks like (row 1 is the column letters, row 2 is the header names, row 3 is example data):
HIJKLMNOPQ
DescriptionNotesDepthBreadthImpactScoreRankGapAvg.Bucket
TEXT TEXT TEXTTEXT TEXT3215423A

<tbody>
</tbody>

I need the new table to look like this:

HIJKLMNOPQR
DescriptionNotesDepthBreadthImpactScoreNotes 2Depth 2Breadth 2Impact 2Score 2

<tbody>
</tbody>


Thanks!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
18,233
Office Version
  1. 2013
Platform
  1. Windows
I looked at this but do not understand your examples. In your first example in row 2 you show Text Text Text
But in your second example you show: 2 2 2 2
 

lawi227

Board Regular
Joined
Mar 17, 2016
Messages
123
Row 1 of each table is the column.
Row 2 is the headers.
Row 3 is example data. "TEXT TEXT TEXT" means that it's just a string of words - not numbers.

In my new table example, I am trying to differentiate the headers. For example, I would need a header called "Notes" in Column I, and I would need another header called "Notes 2" in Column N.

Sorry I'm not very good at posting my tables into this forum. Still a beginner user of the forum..
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,110
Messages
5,768,153
Members
425,458
Latest member
Jaspal1996

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
Top