Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Automate Excel tasks

Posted on 2012-03-25
3
Medium Priority
?
345 Views
Last Modified: 2012-03-25
So that I can award more points, I am breaking down my requirements into several parts.  Please refer to the attached Excel file.

Part A:
 I would like a macro which:
-      Formats the numbers in Cols E to H as numbers with 1000 separator (,) and  no decimal places
-      Inserts column totals in Cols E to H
-      Inserts cross-totals in Col I

Thanks.
Book1.xlsx
0
Comment
Question by:RishiSingh05
[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
3 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 2000 total points
ID: 37762672
I wasn't 100% sure what you meant by cross-sums but I've added a formula in each row of I that sums columsn E to H.


Also, I wasn't sure if you wanted that sum to also include the row with the column sums, if you do use this.
    Set rng = Range("I2:I" & LastRow+1)
    

Open in new window


Anyway, here's the code.
Dim rng As Range
Dim LastRow As Long

    LastRow = Range("A" & Rows.Count).End(xlUp).Row
    
    Set rng = Range("E2:H" & LastRow)
    
    rng.NumberFormat = "#,000"
    
    Set rng = Range("E" & LastRow + 1 & ":H" & LastRow + 1)
    
    rng.Formula = "=SUM(R2C:R[-1]C)"
    
    
    Set rng = Range("I2:I" & LastRow)
    
    rng.Formula = "=SUM(E2:H2)"

Open in new window

0
 

Author Comment

by:RishiSingh05
ID: 37762678
Thanks.  I will test it out and let you know.
0
 

Author Comment

by:RishiSingh05
ID: 37762682
I will post Part B shortly.  Thanks.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

705 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