Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
x y scatter chart series ranges reset to x(range) = y(range) | Charts and Charting in Excel | |||
Selecting range in list of range names depending on a cell informa | Excel Discussion (Misc queries) | |||
formula to sort a range so that it matches the exact rows of a column that is outside that range? | Excel Discussion (Misc queries) | |||
How to count dates within a certain range in a column with mutiple date range entries | Excel Worksheet Functions |