# Thread: Macro sum problem in excel 2007

1. Member
Join Date
Dec 2008
Posts
63

## Macro sum problem in excel 2007

I am having problem with macros in Excel 2007. I created the following macro: If Range ( "M10") = 2 Then Range ( "K20"). Copy Range ( "D3") This little function allows me to paste the contents of the cell K20 in a table cell D3.
So far, no problem. The concern is that I wanted the cell K20 corresponds to the sum of cells M17 + M18 + M19. And there, it's corse. Excel installation error # REF! from the time when the formula contains a sum.
For the moment, so I have to manually enter the number 9 (sum of M17-18-19) for example, so that the button on the copy which I support in cell D3.

Can anyone know tips to do this ?

Thanks

2. Member
Join Date
Dec 2008
Posts
27

## Re: Macro sum problem in excel 2007

For the Sum function is a beach to be given.
= SUM (A1: A20)
and nothing else.

3. Member
Join Date
May 2008
Posts
90

## Re: Macro sum problem in excel 2007

K20 in the box I put the following formula
IF (ESTERREUR (M17 + M18 + M19 );""; M17 + M18 + M19)
This formula is the sum of your 3 cells, and if ever there is an error (eg there is a character instead of a number in the formula), and it is the emptiness in your case. Explanation: ESTERREUR () checks what is inside the parenthesis, if it # returns a ref, then it will be there after 1st semicolon, in this case it is the "" nothing, but you can replace by 0. Otherwise, if there is no error and therefore the amount is correct and it is there after the 2nd semi-colon, or in our case ta sum (M17 + M18 + M19).