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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,323
Members
449,077
Latest member
jmsotelo

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