Solved

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

Posted on 2014-03-13
2
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

632 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