Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Add a range to antoher range

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default Add a range to antoher range

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


  #3   Report Post  
Posted to microsoft.public.excel.misc
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
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default Add a range to antoher range

Glad you got to a solution, Jay.

Just one thing - you don't need to write:

If IsNumeric(...) = True ... etc

You can just write this as:

If IsNumeric(...) And IsNumeric(...) Then

Hope this helps.

Pete

On Oct 30, 7:33*pm, jlclyde wrote:
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- Hide quoted text -

- Show quoted text -


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
x y scatter chart series ranges reset to x(range) = y(range) Brakerm19 Charts and Charting in Excel 4 September 26th 06 11:13 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
formula to sort a range so that it matches the exact rows of a column that is outside that range? steveo Excel Discussion (Misc queries) 1 June 18th 06 02:05 AM
How to count dates within a certain range in a column with mutiple date range entries Krisjhn Excel Worksheet Functions 2 September 1st 05 01:59 PM


All times are GMT +1. The time now is 06:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"