?
Solved

Insert Row and Format Excel Cell

Posted on 2013-05-14
4
Medium Priority
?
419 Views
Last Modified: 2013-05-29
I need an EXCEL VBA example on how to insert a row and format the cells.

On the spreadsheet I have these rows.
      Col A            Col B            Col C
Company A      Winget 1       10,000
Company A      Winget 3        10,000
Company A      Winget 4       20,000
Company A      Winget 5        30,000
Company B      Winget 1       10,000
Company B     Winget 3        20,000
Company B      Winget 4       30,000
Company B     Winget 5        40,000



I want to insert a line below these rows using VBA. Each cell in right justifed, Bolded and the third column cell would sum Col C. The row will be light blue in colour.

The result would look like this  

      Col A            Col B            Col C
Company A      Winget 1       10,000
Company A      Winget 3        10,000
Company A      Winget 4       20,000
Company A      Winget 5        30,000
                            Totals:        60,000
Company B      Winget 1       10,000
Company B     Winget 3        20,000
Company B      Winget 4       30,000
Company B     Winget 5        40,000
                            Totals:       100,000

With each totals row highlighted in blue and all cells bolded and right justified.
0
Comment
Question by:Idarac
[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
4 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 39166472
Out of curiosity, why not simply use the Subtotals feature?

Or even better, a PivotTable?
0
 
LVL 1

Author Comment

by:Idarac
ID: 39166523
Can I get the effect I need using the subtotals feature?

Cannot use a pivot table.
0
 
LVL 1

Author Comment

by:Idarac
ID: 39166549
I am not familiar with the subtotals feature....
0
 
LVL 33

Accepted Solution

by:
Rob Henson earned 1500 total points
ID: 39167685
Subtotal feature is on the Data menu.

Fairly simple procedure, the only pre-requisite I would suggest you check on before initiating the feature is to check that the column for which you want the totals based on, eg Company in your example, is sorted because the subtotal feature relies on a change in value in a column to insert a row and apply the subtotal.

The subtotal feature will only add the rows with the subtotals, with the wording "Total Company A" or something similar. If you want specific text on the total row, I suspect you could achieve with edit/replace.

The formatting would have to be done separately.

The whole thing could be run through a single macro.

Thanks
Rob H
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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‚Ķ

762 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