ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros (https://www.excelbanter.com/excel-programming/415663-macros.html)

BAS

Macros
 
hi,
I would like to know how to define a macro that checks column A,
(1) if non-empty, adds all the values present in it
(2) if empty, jumps to column B and adds the values present there.

I tried it out but with no success. Can somebody help please?
Its pretty urgent.

Thanking you in advance.

joel

Macros
 
Sub Addcolumns()

total = WorksheetFunction.Sum(Columns("A"))
If total = 0 Then
total = WorksheetFunction.Sum(Columns("B"))
End If

End Sub


"BAS" wrote:

hi,
I would like to know how to define a macro that checks column A,
(1) if non-empty, adds all the values present in it
(2) if empty, jumps to column B and adds the values present there.

I tried it out but with no success. Can somebody help please?
Its pretty urgent.

Thanking you in advance.



All times are GMT +1. The time now is 01:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com