Sum Blank

billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
Hello All

Trying to sum range above when cell is Blank. Using the below code.

Code:
Sub SumBlank()Dim lr&
Dim i&
lr = Cells(Rows.Count, 1).End(xlUp).Row
total = 0


With ActiveSheet
For i = 1 To lr + 1
If Cells(i, 1) <> "" Then
total = total + Cells(i, 1)
End If
Next
End With
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
@ Fluff Works perfect. Why is there a need to include an else.

@ Mr. Rothstein. Missed this one - using the SpecialCells Method is also adequate.
Just wondering... you describe Fluff's code as being "perfect" but my code as being only "adequate"... did my code not do something correctly for you? If so, let me know what and I will see if I can address the problem.
 
Upvote 0
not at all Mr.Rothstein. Your assistance with this and all the help I've received is exceptional!!!

I'm actually learning and attempting to determine which methods are easier for me. The initial code I posted is a bit easier to interpret however I believe not as proficient as your method.
 
Upvote 0

Forum statistics

Threads
1,214,589
Messages
6,120,415
Members
448,960
Latest member
AKSMITH

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