Insert a new row and merge the cells in a new row

SWETHAKHATRI88

New Member
Joined
Jul 29, 2022
Messages
10
Office Version
  1. 2021
Platform
  1. MacOS
I am trying to write a VBA code where if there is a value called 1234 in Column A, a new row needs to be inserted above with a value. For all the new rows inserted, Columns A and B should be merged. Can anyone help with the code for the merge part?

My code is as below

WithCells.Find("1234")
.EntireRow.Insert
Cells(.Row-1,"A") = "1.TEST1234"
END WITH

Thanks
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Is there only one occurrence of "1234" in column A or can there be more than one?
 
Upvote 0
Try:
VBA Code:
Sub InsertRow()
    With Range("A:A").Find("1234")
        .EntireRow.Insert
        Cells(.Row - 1, "A") = "1.TEST1234"
        Cells(.Row - 1, "A").Resize(, 2).Merge
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,970
Messages
6,122,514
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top