Merge Cells run-time error '1004'

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Could anyone help me about the problem with this line of Macro?

Worksheets("DIFF").Range(Cells(CommonRowInd, CommonColInd),
Cells(CommonRowInd + 1, CommonColInd)).Select
Selection.Merge

When I debug, CommonRowInd is 1 and CommonColInd is 25 (as expected). I try
to merge two cells, but I have this problem.

Any suggestions?
 
darxoul napisal(a):
Could anyone help me about the problem with this line of Macro?

Worksheets("DIFF").Range(Cells(CommonRowInd, CommonColInd),
Cells(CommonRowInd + 1, CommonColInd)).Select
Selection.Merge

When I debug, CommonRowInd is 1 and CommonColInd is 25 (as expected). I try
to merge two cells, but I have this problem.

Any suggestions?

is Worksheets("DIFF") active worksheet?
it should be active to select
if its active u can
...... RowInd, CommonColInd), Cells(CommonRowInd + 1,
CommonColInd)).Merge
without selecting it
mcg
 
Sub abc()
CommonRowInd = 1
CommonColInd = 25
With Worksheets("DIFF")
.Range(.Cells(CommonRowInd, CommonColInd), _
.Cells(CommonRowInd + 1, CommonColInd)).Merge
End With
End Sub

worked fine for me on a new sheet. It didn't require the the sheet DIFF be
active.
 
Yes, it works this way.

Thanks a lot.

But why?

Tom Ogilvy said:
Sub abc()
CommonRowInd = 1
CommonColInd = 25
With Worksheets("DIFF")
.Range(.Cells(CommonRowInd, CommonColInd), _
.Cells(CommonRowInd + 1, CommonColInd)).Merge
End With
End Sub

worked fine for me on a new sheet. It didn't require the the sheet DIFF be
active.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top