Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I make a excel sheet, Lock column A and rows 1. I want to delete range B4:Q8 when I press button but "Delete method of range class failed" get error mesage? wonder why. thanks for helps..

VB
Sheets("Home").Range(Cells(4, 2), Cells(Cells(Rows.Count, "b").End(xlUp).Row, 17)).Delete
Posted
Updated 11-Mar-15 5:20am
v2
Comments
ZurdoDev 11-Mar-15 11:40am    
If the sheet is protected then you can't delete from it.
gwlrs 12-Mar-15 9:13am    
Thanks for answer. I want to delete unprotected or unlocked cells. if the sheet is protected, are any cells deleted in the sheet event though unlocked cells. my button click include 'delete cells' event. Can't I?
[no name] 11-Mar-15 22:53pm    
Your delete range is not in protected row or column, I think it should can be delete.

You can't, WorkSheet Protection is done to prevent cells deletion.

You can only clear the content of unlocked cells.
 
Share this answer
 
Try to unlock the sheet first, delete the data and protect again.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900