Hi group,
I'm having some problems with a For/Next loop that has a "UnMerge" inside it. After the copy and paste is completed, the routine stops and doesn't complete the "Next" portion of the loop. Are they any thoughts as to why? What should I do to fix this?
Here is the code I'm using:
In advance, thanks for you explanations and ideas to fix. I look forward to hearing from you.
Don
I'm having some problems with a For/Next loop that has a "UnMerge" inside it. After the copy and paste is completed, the routine stops and doesn't complete the "Next" portion of the loop. Are they any thoughts as to why? What should I do to fix this?
Here is the code I'm using:
Code:
For rowNumber = 2 To 10000
Cells(rowNumber, 4).Select
cellDVal = Range("D" & rowNumber).Value
If cellDVal = "" Then
Exit Sub
End If
If ActiveCell.MergeCells = True Then
rowsMerged = ActiveCell.MergeArea.Rows.Count
Range("D" & rowNumber).UnMerge
Range("D" & rowNumber).Copy Range("D" & rowNumber & ":D" & rowNumber + (rowsMerged - 1)) ' The routine is exiting here.
rowNumber = rowNumber + (rowsMerged - 1)
End If
Next rowNumber
In advance, thanks for you explanations and ideas to fix. I look forward to hearing from you.
Don
Last edited: