VBA to prevent deletion of a single COLUMN only ?

spyrule

Board Regular
Joined
Aug 21, 2015
Messages
114
Hello,

I know of the code:

Code:
[COLOR=#000000][FONT=verdana]Target.Address = Target.EntireColumn.Address[/FONT][/COLOR]

to help prevent the deletion of columns.

However, how do I change this to ONLY prevent the deletion of the A column and A Column ROWS only?

I'm assuming I need to add an IF statement to detect what the target.address is, except, I'm unsure how to detect only for a specific column, or if a cell is in the A column.

Any help is appreciated!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

baitmaster

Well-known Member
Joined
Mar 12, 2009
Messages
2,042
you could look to see if your target and columns(x) have the same address. Or you could look at the intersect of the two ranges, i.e. the point at which they overlap

e.g.1 if target.address = columns(1).address then ' target is column A

e.g.2 if not intersect(target, columns(1)) is nothing then ' there is an overlap between the 2 ranges
 
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,163,867
Messages
5,834,096
Members
430,260
Latest member
MANICX100

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