View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Damian Damian is offline
external usenet poster
 
Posts: 71
Default Getting Error in Micro(for Loop)

I am trying to add extra rows and the merge certatin columns together, but I
am getting a

Run-Time error '1004'
Application-defined or object-defined error

How come?

Here is the code:
Sub AddExtraRows()

ActiveSheet.Unprotect Password:="eli"
Rows("32:80").Insert Shift:=xlDown

For i = 32 To 103
Range(Cells(i, 3), Cells(i, 6)).Merge
Next i

For j = 32 To 103
Range(Cells(j, 7), Cells(j, 12)).Merge
Next j

For k = 32 To 103
Range(Cells(k, 13), Cells(k, 15)).Merge
Next k

With ActiveSheet
.Protect Password:="eli"
.EnableSelection = xlUnlockedCells
End With
End Sub