0
Sub MergeCells()  

For i = 0 To 5996 Step 1
     ActiveSheet.Range("G4").Offset(i, 0).Resize(0, 18).Merge 
Next i  

End Sub

Thhis gives Error 1004 - I simply want to merge 18 cells across 5996 rows starting Row 4

1 Answer 1

1

You cannot .Resize(0, 18), the zero is not a valid option.

If you want to keep the existing number of rows while resizing, omit the argument:

.Resize(, 18)

Better yet, remove the loop and merge across in a single command:

Sub MergeCells()
    ActiveSheet.Range("G4").Resize(5997, 18).Merge True
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.