Macro for sum up and sorting

shawrod

Active Member
Joined
Oct 1, 2010
Messages
399
I am looking for a simple macro that sums up all cells on C and enter result on the last empty cell of C column of the worksheet and same thing with columns D-H. On the last cells of Columns G and H that has the result , set cell format to $. Then I would like to select the whole data on the worksheet except for the last row and sort it by column I from largest to smallest. Can anyone help?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Please post the code as you have written it and highlight the line in question 'cos i cant seem to see this line in the code you posted
 
Upvote 0
.Row in Bold

Code:
Range("A" & Rows.Count).End(xlUp ).[B]Row [/B]
Selection.RowHeight = 39
  
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorLight2
        .TintAndShade = 0.799981688894314
        .PatternTintAndShade = 0
    End With
    With Selection.Font
        .Name = "Calibri"
        .FontStyle = "Bold"
        .Size = 11
       
    End With
  
End Sub
 
Last edited:
Upvote 0
Hi,

i think you will need to assign it to a variable

try

dim lrow as longlrow = Range("A" & Rows.Count).End(xlUp ).Row
 
Upvote 0
Sure you can just say
Rich (BB code):
lastrow = Range("A" & Rows.Count).End(xlUp ).Row
and refer to it using lastrow subsequently
 
Upvote 0
lastrow = Range("A" & Rows.Count).End(xlUp ).Row

The above code worked but it didn’t exactly do what I wanted. It only highlighted the last cell on H where it should have changed the format of all last cells from A-I. Any Idea why?

 
Upvote 0
Maybe if you could just explain your request, we could help with a code. But in any case to change the number format for the lastrow on columns A-L I use something like this that loops from column to column

Code:
For I = 1 To 10   
    lastrow = Cells(Row.Count, I).End(xlUp).Row
    Cells(lastrow, I).Select
    Selection.NumberFormat = "$#,##00.00"
Next I
 
Upvote 0
What I am trying to do is. To resize the height of the last rows (A-I) of the data to 39. Then Bold the font and fill in the color that I have selected. Does it make sense?
 
Upvote 0
Something like dis maybe
Code:
For K = 1 To 10    
    lastrow = Cells(Row.Count, K).End(xlUp).Row
    Cells(lastrow, K).Select
    
    Selection.RowHeight = 39
  
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorLight2
        .TintAndShade = 0.799981688894314
        .PatternTintAndShade = 0
    End With
    With Selection.Font
        .Name = "Calibri"
        .FontStyle = "Bold"
        .Size = 11
       
    End With
    
Next K
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top