Hello i am geting a ruin time error 1004 unable to set the locked property of the range class in my code below
What my code is doing is it is unlocking a cell, the cell is merged so i figured just do it for the two cells in which got merged, but it will loop through and go X amount of rows down and X amount of columns over, so should go through the first batch of columns which will have another for loop inside it to go through X amount of rows then go to the next batch column do the same with the rows and so on
is it because of the .cells with the .locked? i saw a lot of .range with .locked is all?
I am getting the run time error here on this line:
main1.Cells(rowNumCol + rowMult, (((i - 1) * (entColAmtCol)) + colNum) + FirstColOffFourCol).Locked = False
What my code is doing is it is unlocking a cell, the cell is merged so i figured just do it for the two cells in which got merged, but it will loop through and go X amount of rows down and X amount of columns over, so should go through the first batch of columns which will have another for loop inside it to go through X amount of rows then go to the next batch column do the same with the rows and so on
is it because of the .cells with the .locked? i saw a lot of .range with .locked is all?
VBA Code:
Sub Unprotect()
Dim entColAmtCol, colNum, SecColOffFourCol, FirstColOffFourCol, rowMultCol, rowNumCol, SG_RowMultCol, rowMult, groupNum, sg, iterAmtCol, i As Integer
Dim page1 As Workbook
Set page1 = Application.ThisWorkbook
Dim page1_ws As Worksheet
Dim page1_list As Worksheet
Set page1_list = page1.Worksheets("List")
Dim num_ent As Integer
num_ent = page1_list.Cells(Rows.count, 2).End(xlUp).Row - 4
Dim main1 As Worksheet
Set main1 = page1.Worksheets("Main")
entColAmtCol = 4
colNum = 4
FirstColOffFourCol = 13
SecColOffFourCol = 14
rowNumCol = 15
rowMultCol = 66
rowMult = 0
iterAmtCol = 11
For i = 1 To num_ent
For groupNum = 1 To iterAmtCol
main1.Cells(rowNumCol + rowMult, (((i - 1) * (entColAmtCol)) + colNum) + FirstColOffFourCol).Locked = False
main1.Cells(rowNumCol + rowMult, (((i - 1) * (entColAmtCol)) + colNum) + SecColOffFourCol).FormulaHidden = False
rowMult = rowMult + rowMultCol
Next groupNum
Next i
End Sub
Next i
I am getting the run time error here on this line:
main1.Cells(rowNumCol + rowMult, (((i - 1) * (entColAmtCol)) + colNum) + FirstColOffFourCol).Locked = False