Runtime Error '1004': Method 'Range' of Object '_Global' failed

Copper Contributor

Am trying to control "protection & FormulaHide" attributes of multiple cells and ranges and I get the following error:

 

Runtime Error '1004': Method 'Range' of Object '_Global' failed

 

Ranges:

Range("A11:C16, D11:E16, G11:H16, J11:K16, M11:N16, P11:Q16, S11:T16, V11:W16, Y11:Z16, AB11:AC16, AE11:AF16, AH11:AI16, AK11:AL16, AN11:AO16, AQ11:AR16, AT11:AU16, AW11:AX16, AZ11:BA16, BC11:BD16, BF11:BG16, BI11:BJ16, A19:C24, D19:E24, G19:H24, J19:K24, M19:N24, P19:Q24, S19:T24, V19:W24, Y19:Z24, AB19:AC24, AE19:AF24, AH19:AI24, AK19:AL24, AN19:AO24, AQ19:AR24, AT19:AU24, AW19:AX24, AZ19:BA24, BC19:BD24, BF19:BG24, BI19:BJ24, A27:C32, D27:E32, G27:H32, J27:K32, M27:N32, P27:Q32, S27:T32, V27:W32, Y27:Z32, AB27:AC32, AE27:AF32, AH27:AI32, AK27:AL32, AN27:AO32, AQ27:AR32, AT27:AU32, AW27:AX32, AZ27:BA32, BC27:BD32, BF27:BG32, BI27:BJ32, A35:C43, D35:E43, G35:H43, J35:K43, M35:N43, P35:Q43, S35:T43, V35:W43, Y35:Z43, AB35:AC43, AE35:AF43, AH35:AI43, AK35:AL43, AN35:AO43, AQ35:AR43, AT35:AU43, AW35:AX43, AZ35:BA43, BC35:BD43, BF35:BG43, BI35:BJ43").Locked = False

3 Replies

@sagarph 

The string in Range("...") is far too long. Split it into 4 lines:

 

Range("A11:C16, D11:E16, G11:H16, J11:K16, M11:N16, P11:Q16, S11:T16, V11:W16, Y11:Z16, AB11:AC16, AE11:AF16, AH11:AI16, AK11:AL16, AN11:AO16, AQ11:AR16, AT11:AU16, AW11:AX16, AZ11:BA16, BC11:BD16, BF11:BG16, BI11:BJ16").Locked = False
Range("A19:C24, D19:E24, G19:H24, J19:K24, M19:N24, P19:Q24, S19:T24, V19:W24, Y19:Z24, AB19:AC24, AE19:AF24, AH19:AI24, AK19:AL24, AN19:AO24, AQ19:AR24, AT19:AU24, AW19:AX24, AZ19:BA24, BC19:BD24, BF19:BG24, BI19:BJ24").Locked = False
Range("A27:C32, D27:E32, G27:H32, J27:K32, M27:N32, P27:Q32, S27:T32, V27:W32, Y27:Z32, AB27:AC32, AE27:AF32, AH27:AI32, AK27:AL32, AN27:AO32, AQ27:AR32, AT27:AU32, AW27:AX32, AZ27:BA32, BC27:BD32, BF27:BG32, BI27:BJ32").Locked = False
Range("A35:C43, D35:E43, G35:H43, J35:K43, M35:N43, P35:Q43, S35:T43, V35:W43, Y35:Z43, AB35:AC43, AE35:AF43, AH35:AI43, AK35:AL43, AN35:AO43, AQ35:AR43, AT35:AU43, AW35:AX43, AZ35:BA43, BC35:BD43, BF35:BG43, BI35:BJ43").Locked = False

Thank you so much @Hans Vogelaar for your quick response, however tried that, but it still wont workit still won't work

@sagarph 

Is the sheet you're applying this to protected at the moment you try to run the code?