Solved

Insert Row and Format Excel Cell

Posted on 2013-05-14
4
407 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 92

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 500 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

737 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