Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Funtion that adds two named ranges

I have the following:

Named ranges within columns A & C (ie A1:A10 is named "Calc" and C1:C10 is
named "Total"). Column A contains a formula that calculates a value based on
fixed data and data entered into column B by a user.

I would like a function that captures the current value of a cell in Column
A and the value of the corresponding cell in Column C. I want these two
values added together and have the new value placed back into Column C. This
function should only act against the selected cells within the range.

Here is an example of what I would like to do:

Column A Column B Column C
1 10 4 0
2 20 3 10
3 40 5 5
4 20 1 20
5 30 5 8
etc..

If Cells C1, C3 & C4 are selected and the function is run, the resulting
values should be: C1 = 10 (A1 + C1), C3 = 45 (A3 + C3), & C4 = 40 (A4 + C4).


Anybody want to give this one a shot?

Thanks

Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Funtion that adds two named ranges

Sub AdjustTotal()

set selection = intersect(Range("Calc"),Selection.EntireRow)
for each cell in Selection
cell.offset(0,2).Value = cell + cell.offset(0,2).Value
Next
End Sub

--
Regards,
Tom Ogilvy



"Matt" wrote in message
...
I have the following:

Named ranges within columns A & C (ie A1:A10 is named "Calc" and C1:C10 is
named "Total"). Column A contains a formula that calculates a value based

on
fixed data and data entered into column B by a user.

I would like a function that captures the current value of a cell in

Column
A and the value of the corresponding cell in Column C. I want these two
values added together and have the new value placed back into Column C.

This
function should only act against the selected cells within the range.

Here is an example of what I would like to do:

Column A Column B Column C
1 10 4 0
2 20 3 10
3 40 5 5
4 20 1 20
5 30 5 8
etc..

If Cells C1, C3 & C4 are selected and the function is run, the resulting
values should be: C1 = 10 (A1 + C1), C3 = 45 (A3 + C3), & C4 = 40 (A4 +

C4).


Anybody want to give this one a shot?

Thanks

Matt



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Funtion that adds two named ranges

Thanks Tom...was able to use a variation of what you gave to get what I
needed.

"Tom Ogilvy" wrote:

Sub AdjustTotal()

set selection = intersect(Range("Calc"),Selection.EntireRow)
for each cell in Selection
cell.offset(0,2).Value = cell + cell.offset(0,2).Value
Next
End Sub

--
Regards,
Tom Ogilvy



"Matt" wrote in message
...
I have the following:

Named ranges within columns A & C (ie A1:A10 is named "Calc" and C1:C10 is
named "Total"). Column A contains a formula that calculates a value based

on
fixed data and data entered into column B by a user.

I would like a function that captures the current value of a cell in

Column
A and the value of the corresponding cell in Column C. I want these two
values added together and have the new value placed back into Column C.

This
function should only act against the selected cells within the range.

Here is an example of what I would like to do:

Column A Column B Column C
1 10 4 0
2 20 3 10
3 40 5 5
4 20 1 20
5 30 5 8
etc..

If Cells C1, C3 & C4 are selected and the function is run, the resulting
values should be: C1 = 10 (A1 + C1), C3 = 45 (A3 + C3), & C4 = 40 (A4 +

C4).


Anybody want to give this one a shot?

Thanks

Matt




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
Max # of named ranges leaftye - ExcelForums.com Excel Discussion (Misc queries) 1 July 14th 05 07:47 PM
help with named ranges please inquirer Excel Programming 3 May 14th 05 01:20 AM
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 PM
Desktop shortcut to a named Excel file - every time I open it adds a "1" to the file name - how to disable? [email protected] Setting up and Configuration of Excel 2 November 27th 04 09:02 PM
named ranges - changing ranges with month selected gr8guy Excel Programming 2 May 28th 04 04:50 AM


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

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

About Us

"It's about Microsoft Excel"