• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Copy 2 rows and insert below the last row with values and Group

I want to write a macro where I copy rows 5 & 6 and insert them with the formatting & formulas below the last row +1 where there is a value in column B. So for example if the last row had a value in column B I would want to skip a blank row and then insert these 2 rows. So if the last row was 40 then I would want to insert these after row 41. Then I want to take these two newly inserted rows and group them together with the top row being the main group and the bottom row hidden until I click the plus sign on the left to expand it. I hope that makes sense.
Lawrence Salvucci
Lawrence Salvucci
1 Solution
pls try

Sub Macro()

    LastRow = Range("B" & Cells.Rows.Count).End(xlUp).Row
    Range("A" & LastRow).Activate
    Application.CutCopyMode = False
    Range("A" & LastRow + 1).Rows.Group
End Sub

Open in new window

Lawrence SalvucciInformation Technology ManagerAuthor Commented:
Perfect! Thank you for the quick response!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now