Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Insert Row and Format Excel Cell

Posted on 2013-05-14
4
Medium Priority
?
423 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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
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 demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

604 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