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!
 

Some videos you may like

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

baitmaster

Well-known Member
Joined
Mar 12, 2009
Messages
2,039
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,658
Messages
5,597,403
Members
414,142
Latest member
Banyangt

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