Solved

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

Posted on 2014-03-13
2
261 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 50

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

756 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