IF Statement Added to VBA Code to Display Blank if Sum Equals 0

lamarh755

New Member
Joined
Jan 28, 2020
Messages
35
Office Version
  1. 2013
I have 4 columns in an excel spreadsheet where the values in each column are added up at the end of the last row. When the sheet is blank, the totals at the bottom show 0. I am trying to have a formula (possibly an IF statement) added to my current formula to make it to where the 4 cells at the bottom of the sheet show blank if the sum equals 0. I tried to use an IF statement but it errors out because I am not sure how to do it using LastRow. Any help would be greatly appreciated.


Dim aLastRow As Long
aLastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row - 3
Range("B" & aLastRow + 1).FormulaR1C1 = "=SUM(R[-" & aLastRow & "]C:R[-1]C)"
Range("E" & aLastRow + 1).FormulaR1C1 = "=SUM(R[-" & aLastRow & "]C:R[-1]C)"
Range("J" & aLastRow + 1).FormulaR1C1 = "=SUM(R[-" & aLastRow & "]C:R[-1]C)"
Range("M" & aLastRow + 1).FormulaR1C1 = "=SUM(R[-" & aLastRow & "]C:R[-1]C)"
 
You are welcome.
Glad I could help (sorry I misunderstood the question initially).
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,224,875
Messages
6,181,514
Members
453,050
Latest member
Obil

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