Autosum at an empty cell in column. Only autosum for visible cells!

Madter

New Member
Joined
Oct 16, 2017
Messages
24
Hi guys.
I have a data sheet which is attached here.
I get a new data sheet like this every day, and that is why i need it to autosum where the red arrows are pointing in the attached picture.
I've used filter so i only need it for the visible cells.

I have this macro;
Code:
Sub AutoSum()
Dim Area As Range, MyColumn As String
MyColumn = "A"
    For Each Area In Columns(MyColumn).SpecialCells(xlConstants, xlNumbers).Areas
        SumAddr = Area.Address(False, False)
        Area.Offset(Area.Count, 0).Resize(1, 1).Formula = "=SUM(" & SumAddr & ")"
    Next Area
End Sub
..where i've tried substituting "xlConstants" with xlCellTypeVisible and deleting xlNumbers, but i can't seem to get it to work.
Any suggestions?

https://www.screencast.com/t/jwSSZNW1Us
Thanks
 
Last edited by a moderator:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Welcome to the board.

See if this helps:
Code:
Sub AutoSum()

    Dim LR  As Long
    
    LR = Cells(Rows.count, 1).End(xlUp).row
    
    MsgBox Application.SUM(Cells(1, 1).Resize(LR).SpecialCells(xlCellTypeVisible))

End Sub
 
Last edited:
Upvote 0
Welcome to the board.

See if this helps:
Code:
Sub AutoSum()

    Dim LR  As Long
    
    LR = Cells(Rows.count, 1).End(xlUp).row
    
    MsgBox Application.SUM(Cells(1, 1).Resize(LR).SpecialCells(xlCellTypeVisible))

End Sub


Thanks! But no, it just gives me a pop-up message saying "0".
 
Upvote 0
Difficult to tell without a better understanding of your sheet or what you can see.

I filled column A with a mix of numbers and characters and blank cells, using a filter, removed the blank cells then ran the code and it summed the numbers only.
 
Upvote 0
1rpGfKzwt

This is what i see. It just says "0". No changes
 
Upvote 0
What are the criteria column A is being filtered on? I can only see letters in column A so the answer of 0 is correct.

If you were not using macro's, what would the formula be on the sheet? Ignore changing numbers of data rows.
 
Upvote 0
The criteria column A is being filtered on is the letter "N", all other letters are deselected. And i need it on column H. And there is no formula on the sheet.
 
Upvote 0
In other words, sum column H if A = "N"?

Try:
Code:
Sub AutoSum()


    MsgBox Application.SUM(Range("H:H").SpecialCells(xlCellTypeVisible))


End Sub
 
Last edited:
Upvote 0
Thanks for the input!
1. I need the autosum to be done in the cell and not as a messagebox.
2. I need the autosum to be inserted at the two empty cells in columns H. Exactly as the code i send in myself, but just for the visible cells
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,136
Members
453,021
Latest member
Justyna P

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