Solved

Insert blank Rows above rows with bold cell entries

Posted on 2012-03-28
3
299 Views
Last Modified: 2012-03-29
Dear Experts:

I wonder whether the following is feasible using VBA:

I got a table with 7 columns and lots of rows

Some of the rows have bold cell entries.

I would like to run a macro that performs the following actions:

The macro is to look for rows with bold entries and insert 4 blank rows above all the rows that contain bold entries.

I have attached a sample file for your convenience.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Inserting-Rows-Before-Rows-Conta.xlsx
0
Comment
Question by:AndreasHermle
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
kgerb earned 500 total points
Comment Utility
Try this.  I think it will do what you want.
Sub AddRowsBeforeBoldEntries()
Dim i As Long, StartRow As Long
StartRow = 4
For i = Cells(Rows.Count, "B").End(xlUp).Row To StartRow Step -1
    With Cells(i, "B")
        If .Value <> "" And .Font.Bold = True Then .Resize(4).EntireRow.Insert
    End With
Next i
End Sub

Open in new window

Kyle
0
 

Author Closing Comment

by:AndreasHermle
Comment Utility
Kyle,

great stuff! Works like a charm.

I am really glad to have the chance to turn to real professionals when it comes to VBA coding.

Thank you very much.

Regards, Andreas
0
 
LVL 12

Expert Comment

by:kgerb
Comment Utility
You're welcome.  Glad I can help.
Kyle
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

728 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

11 Experts available now in Live!

Get 1:1 Help Now