Solved

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

Posted on 2014-03-13
2
257 Views
Last Modified: 2014-03-13
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.
0
Comment
Question by:Lawrence Salvucci
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39926266
Hi,
pls try

Sub Macro()

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

Open in new window

Regards
0
 
LVL 1

Author Closing Comment

by:Lawrence Salvucci
ID: 39926278
Perfect! Thank you for the quick response!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now