Thursday 15 January 2015

Excel VBA Getting rid of error 1004 With Hide and unhide Macros when sheets protected -



Excel VBA Getting rid of error 1004 With Hide and unhide Macros when sheets protected -

i'm getting error 1004 when hiding , unhiding rows on sheet, sheet protected allow user format rows allows user hide , unhide rows on excel sheet. althought code below work give error 1004 telling me sheets protected need rid of, believe issue because i'm selecting cells want hide/unhide i'm not sure how modify tell cell range wish hide/unhide

sub show_menu() rows("20:20").select rows("20:44").select selection.entirerow.hidden = false rows("45:45").select rows("45:128").select selection.entirerow.hidden = true end sub

try this:

sub show_menu() sheets("yoursheetname").unprotect password:="abc" rows("20:20").select rows("20:44").select selection.entirerow.hidden = false rows("45:45").select rows("45:128").select selection.entirerow.hidden = true sheets("yoursheetname").protect password:="abc", allowformattingrows:=true end sub

appended:

allowformattingcells:=true ' allow formatting

and

sheets("yoursheetname").enableselection = xlunlockedcells ' allow unlocked cell in protected book

excel excel-vba

No comments:

Post a Comment