简体   繁体   中英

Excel VBA delete blank rows on password protected sheet

I am running a macro to delete empty rows if all entries of the row are blank. I have the code however, since the sheet is password protected, a message displays saying to remove the password and unprotect worksheet first. I need the sheet to be locked at all stages but also need to delete the empty rows. If anyone can help me enter this part of the code so this problem is overcome! The code I currently have is:

heets("Media Plan").Select Cells.Select Selection.SpecialCells(xlCellTypeBlanks).Select Selection.Delete Shift:=xlUp

Many Thanks!

What you should do is unprotect the sheet, delete empty rows and then turn the protection back on.

Sheets("Media Plan").Select
 ActiveSheet.unprotect Password:="password"
    Cells.Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Selection.Delete Shift:=xlUp
 ActiveSheet.protect Password:="password"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM