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

%3CLINGO-SUB%20id%3D%22lingo-sub-1857066%22%20slang%3D%22en-US%22%3ERuntime%20Error%20'1004'%3A%20Method%20'Range'%20of%20Object%20'_Global'%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1857066%22%20slang%3D%22en-US%22%3E%3CP%3EAm%20trying%20to%20control%20%22protection%20%26amp%3B%20FormulaHide%22%20attributes%20of%20multiple%20cells%20and%20ranges%20and%20I%20get%20the%20following%20error%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERuntime%20Error%20'1004'%3A%20Method%20'Range'%20of%20Object%20'_Global'%20failed%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERanges%3A%3C%2FP%3E%3CP%3ERange(%22A11%3AC16%2C%20D11%3AE16%2C%20G11%3AH16%2C%20J11%3AK16%2C%20M11%3AN16%2C%20P11%3AQ16%2C%20S11%3AT16%2C%20V11%3AW16%2C%20Y11%3AZ16%2C%20AB11%3AAC16%2C%20AE11%3AAF16%2C%20AH11%3AAI16%2C%20AK11%3AAL16%2C%20AN11%3AAO16%2C%20AQ11%3AAR16%2C%20AT11%3AAU16%2C%20AW11%3AAX16%2C%20AZ11%3ABA16%2C%20BC11%3ABD16%2C%20BF11%3ABG16%2C%20BI11%3ABJ16%2C%20A19%3AC24%2C%20D19%3AE24%2C%20G19%3AH24%2C%20J19%3AK24%2C%20M19%3AN24%2C%20P19%3AQ24%2C%20S19%3AT24%2C%20V19%3AW24%2C%20Y19%3AZ24%2C%20AB19%3AAC24%2C%20AE19%3AAF24%2C%20AH19%3AAI24%2C%20AK19%3AAL24%2C%20AN19%3AAO24%2C%20AQ19%3AAR24%2C%20AT19%3AAU24%2C%20AW19%3AAX24%2C%20AZ19%3ABA24%2C%20BC19%3ABD24%2C%20BF19%3ABG24%2C%20BI19%3ABJ24%2C%20A27%3AC32%2C%20D27%3AE32%2C%20G27%3AH32%2C%20J27%3AK32%2C%20M27%3AN32%2C%20P27%3AQ32%2C%20S27%3AT32%2C%20V27%3AW32%2C%20Y27%3AZ32%2C%20AB27%3AAC32%2C%20AE27%3AAF32%2C%20AH27%3AAI32%2C%20AK27%3AAL32%2C%20AN27%3AAO32%2C%20AQ27%3AAR32%2C%20AT27%3AAU32%2C%20AW27%3AAX32%2C%20AZ27%3ABA32%2C%20BC27%3ABD32%2C%20BF27%3ABG32%2C%20BI27%3ABJ32%2C%20A35%3AC43%2C%20D35%3AE43%2C%20G35%3AH43%2C%20J35%3AK43%2C%20M35%3AN43%2C%20P35%3AQ43%2C%20S35%3AT43%2C%20V35%3AW43%2C%20Y35%3AZ43%2C%20AB35%3AAC43%2C%20AE35%3AAF43%2C%20AH35%3AAI43%2C%20AK35%3AAL43%2C%20AN35%3AAO43%2C%20AQ35%3AAR43%2C%20AT35%3AAU43%2C%20AW35%3AAX43%2C%20AZ35%3ABA43%2C%20BC35%3ABD43%2C%20BF35%3ABG43%2C%20BI35%3ABJ43%22).Locked%20%3D%20False%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1857066%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1857197%22%20slang%3D%22en-US%22%3ERe%3A%20Runtime%20Error%20'1004'%3A%20Method%20'Range'%20of%20Object%20'_Global'%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1857197%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F858763%22%20target%3D%22_blank%22%3E%40sagarph%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20string%20in%20Range(%22...%22)%20is%20far%20too%20long.%20Split%20it%20into%204%20lines%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERange(%22A11%3AC16%2C%20D11%3AE16%2C%20G11%3AH16%2C%20J11%3AK16%2C%20M11%3AN16%2C%20P11%3AQ16%2C%20S11%3AT16%2C%20V11%3AW16%2C%20Y11%3AZ16%2C%20AB11%3AAC16%2C%20AE11%3AAF16%2C%20AH11%3AAI16%2C%20AK11%3AAL16%2C%20AN11%3AAO16%2C%20AQ11%3AAR16%2C%20AT11%3AAU16%2C%20AW11%3AAX16%2C%20AZ11%3ABA16%2C%20BC11%3ABD16%2C%20BF11%3ABG16%2C%20BI11%3ABJ16%22).Locked%20%3D%20False%3CBR%20%2F%3ERange(%22A19%3AC24%2C%20D19%3AE24%2C%20G19%3AH24%2C%20J19%3AK24%2C%20M19%3AN24%2C%20P19%3AQ24%2C%20S19%3AT24%2C%20V19%3AW24%2C%20Y19%3AZ24%2C%20AB19%3AAC24%2C%20AE19%3AAF24%2C%20AH19%3AAI24%2C%20AK19%3AAL24%2C%20AN19%3AAO24%2C%20AQ19%3AAR24%2C%20AT19%3AAU24%2C%20AW19%3AAX24%2C%20AZ19%3ABA24%2C%20BC19%3ABD24%2C%20BF19%3ABG24%2C%20BI19%3ABJ24%22).Locked%20%3D%20False%3CBR%20%2F%3ERange(%22A27%3AC32%2C%20D27%3AE32%2C%20G27%3AH32%2C%20J27%3AK32%2C%20M27%3AN32%2C%20P27%3AQ32%2C%20S27%3AT32%2C%20V27%3AW32%2C%20Y27%3AZ32%2C%20AB27%3AAC32%2C%20AE27%3AAF32%2C%20AH27%3AAI32%2C%20AK27%3AAL32%2C%20AN27%3AAO32%2C%20AQ27%3AAR32%2C%20AT27%3AAU32%2C%20AW27%3AAX32%2C%20AZ27%3ABA32%2C%20BC27%3ABD32%2C%20BF27%3ABG32%2C%20BI27%3ABJ32%22).Locked%20%3D%20False%3CBR%20%2F%3ERange(%22A35%3AC43%2C%20D35%3AE43%2C%20G35%3AH43%2C%20J35%3AK43%2C%20M35%3AN43%2C%20P35%3AQ43%2C%20S35%3AT43%2C%20V35%3AW43%2C%20Y35%3AZ43%2C%20AB35%3AAC43%2C%20AE35%3AAF43%2C%20AH35%3AAI43%2C%20AK35%3AAL43%2C%20AN35%3AAO43%2C%20AQ35%3AAR43%2C%20AT35%3AAU43%2C%20AW35%3AAX43%2C%20AZ35%3ABA43%2C%20BC35%3ABD43%2C%20BF35%3ABG43%2C%20BI35%3ABJ43%22).Locked%20%3D%20False%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1858354%22%20slang%3D%22en-US%22%3ERe%3A%20Runtime%20Error%20'1004'%3A%20Method%20'Range'%20of%20Object%20'_Global'%20failed%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1858354%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20so%20much%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3Bfor%20your%20quick%20response%2C%20however%20tried%20that%2C%20but%20it%20still%20wont%20workit%20still%20won't%20work%3C%2FP%3E%3C%2FLINGO-BODY%3E
New 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?