Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-03-13
2
Medium Priority
?
265 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

721 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