View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
jlclyde jlclyde is offline
external usenet poster
 
Posts: 410
Default Add a range to antoher range

On Oct 30, 2:27*pm, Pete_UK wrote:
Do you mean that you want 10 results in, say, C1:C10, or that you want
one result of them all added together?

When you say "skip cells if either of them are text", do you mean you
want to ignore both A and B cells on that row if one contains text, or
that you don't want to include the text value in the addition because
it will cause an error?

Are you trying to do this in a macro?

Pete

On Oct 30, 7:15*pm, jlclyde wrote:



I have a 2 ranges of cells that are equal size and I would ilke to add
them together. *Here is where I am drawing a blank. *say
range("A1:A10" is the first range and Range("B1:B10") is the 2nd
range. *I woudl like to add A1 to B1 and A2 to B2 and so on. *I want
to skip cells if either one of them are text. *I was thinking For
each.... but do nto know what this would look like. *Any help would be
greatly appreciated.


Thanks,
Jay- Hide quoted text -


- Show quoted text -


Pete,
I am trying to do this in a macro and this is what I have come up with
and it seems to work. Apparently all I needed to do was post and then
the idea of isnumeric came to me. As you can see from the code I was
trying to add the As to the Bs in column C and skip any of the cells
where a or b was not a number. Here is the code I am using if any one
is interested. Also if anyone knows a better way, I am open to
suggestions.


Sub AddRows()
Dim rng1 As Range
Dim i
Set rng1 = Range("A20:A25")

For Each i In rng1
If IsNumeric(i.Value) = True And IsNumeric(i.Offset(0,
1).Value) = True Then
i.Offset(0, 2).Value = i.Value + i.Offset(0, 1).Value
Else
GoTo E
End If
E:
Next i
End Sub
Thanks,
Jay