Solved

Insert blank Rows above rows with bold cell entries

Posted on 2012-03-28
3
301 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
ID: 37778120
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
ID: 37779212
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
ID: 37781526
You're welcome.  Glad I can help.
Kyle
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

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,…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

773 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