You cannot lock a cell that is part of a range of merged cells unless it is the upper- left corner cell. I' d like to use the array technique for charting to avoid showing large area of data on the worksheet. You may receive a “ Run- time error 1004? error message when you programmatically set a large array string to a range in Excel. I cant seem to get all the values of array a. the code results in a( 1) being written a 100 times. The default for VBA is to have zero- based arrays ( unless you change the option). To change or edit an array formula, you need to follow some rules, especially if you have multi- cell formulas. You can' t delete cells in an array formula ( you' ll see a " You cannot change part of an array" error), but you can delete the entire. Print displays all the cells is that every time your code changes a cell, another change event is triggered. GoTo 0 End If Next GoTo ExitSub: Error: If Err. Number = 1004 Then ' 1004 - > " You cannot change part of an array. Avoid merged cells. They make life harder.
Go through all the worksheets and unmerge merged cells before you run the macro. Instead of merged cells use " Center across selection" in the Alignment tab of the Format dialog. If the range is an array range ( a block of cells that shares a single array formula) then the FormulaArray property. Because we want the A2 and B2 references to adjust as we ' fill' the array formula down the column, we cannot use the Range. Run- time error ' 1004' : ' Unable to set the FormulaArray property of the Range class'. 1 You Are Trying To Change Part Of An Array Range. I created a spreadsheet in Excel. I went to edit it today and got the message " You cannot change part of an Array". I do not knowingly have any arrays on this spreadsheet, so I don' t know what array the error is referring to. You can use a second array to store the cell lengths that are too long, and separately iterate over these. array that reads in the range; Sets up a second blank variant of equal size to the first array; Tests each part of the array. Perhaps your code is behind Sheet1, so when you change the focus to Sheet2 the objects cannot be found?
You may receive a " Run- time error 1004" error message when you programmatically set a large array string to a. As commented, you cannot change part of an array. So try this: Dim formRange As Range, arrForm As String With Sheets( " Sheet1" ) Set formRange = Range(. Range( " G2" ), _. End( xlToRight) ) arrForm.