code for inserting a column

roedem

New Member
Joined
May 8, 2002
Messages
4
I would like to make a command button that will insert a column in another excel sheet within the same workbook and add certain information. Can this be done?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I'm new at recording macro's and writing any sort of VBA code. Everytime I try to do anything with a macro it says the macros in this project are disabled and to find help on how to enable the macros. It wasn't helpful at all on how to enable macros. any information you can provide would be great. Thanks.
 
Upvote 0
Insert a button, then put this code in the button:

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select

Of course, replace A:A with where you want the row to be inserted. Do you need to tell it every time a different place to insert the row?

HTH
-Corticus
 
Upvote 0
Thanks for the info
yes, I guess the columns would have to be inserted after the last column with information. how would i incorporate that into the macro. also how do i not tell it to disable macros everytime i open the sheet up if macros was never enabled?
 
Upvote 0
go to Tools-Macro-Security and lower your security setting, as far as inserting to column at the end, I would like to know myself!

Corticus
 
Upvote 0
I tried the macro security setting and the same message pops up
"The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros." and the title of that little pop up msgbox is from Visual Basic.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,165
Members
448,870
Latest member
max_pedreira

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