Hi Thanks for visiting my post. I have a task to insert a row based on the value of a cell.
However some cells are merged cells, some unmerged. I have tried code below. But it does not work with "type mismatch" error:-
I do not know the exact location of the merged cell.
Any expert knows how to modify it?
----------------------------------
Dim rng2 As Range
For Each rng2 In Range("A5", "J30")
If rng2.value="Myvalue" Then
rng2.entirerow.insert
Elseif rng2.MergeCells Then
if rng2.MergeArea.Value = "Myvalue" Then
rng2.entirerow.insert
End If
next
------------------------
Thanks v. much
However some cells are merged cells, some unmerged. I have tried code below. But it does not work with "type mismatch" error:-
I do not know the exact location of the merged cell.
Any expert knows how to modify it?
----------------------------------
Dim rng2 As Range
For Each rng2 In Range("A5", "J30")
If rng2.value="Myvalue" Then
rng2.entirerow.insert
Elseif rng2.MergeCells Then
if rng2.MergeArea.Value = "Myvalue" Then
rng2.entirerow.insert
End If
next
------------------------
Thanks v. much