ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Column Delete (https://www.excelbanter.com/excel-programming/328813-column-delete.html)

Henry

Column Delete
 
Hi
I created this simple macro through use of the recorder...

Private Sub commandbutton4_click()

Columns(ActiveCell.Column).Delete

End Sub

It works fine, but I would like to protect Col 1:3 from being deleted. I
would also like to add worksheet protection but the code wont run if the
sheet is protected and if I add Unprotect to the code then Col 1:3 would
still be able to be deleted. How can I modify to accomplish this.
Thanks!

Toppers

Column Delete
 

Private Sub commandbutton4_click()

If Activecell.Column 3 then Columns(ActiveCell.Column).Delete

End Sub


"Henry" wrote:

Hi
I created this simple macro through use of the recorder...

Private Sub commandbutton4_click()

Columns(ActiveCell.Column).Delete

End Sub

It works fine, but I would like to protect Col 1:3 from being deleted. I
would also like to add worksheet protection but the code wont run if the
sheet is protected and if I add Unprotect to the code then Col 1:3 would
still be able to be deleted. How can I modify to accomplish this.
Thanks!



All times are GMT +1. The time now is 07:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com