Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Dyamic Ranges

I was wondering if i could do this, if so how?

I have a sum that goes through the same row. Everytime i insert a column i
want it to automatically to include that inserted range.

Example:
A B C D
1
2
3

Cell C1 is suming Ranges A1:B1. Now if i insert the column before column C,
i want the sum to be able to pick up that inserted range to sum ranges A1:C1
automatically

is there a way??

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dyamic Ranges

=SUM(INDIRECT("A"&ROW()&":"&ADDRESS(ROW(),COLUMN()-1)))

--
Regards,
Tom Ogilvy


"Andy" wrote in message
...
I was wondering if i could do this, if so how?

I have a sum that goes through the same row. Everytime i insert a column

i
want it to automatically to include that inserted range.

Example:
A B C D
1
2
3

Cell C1 is suming Ranges A1:B1. Now if i insert the column before column

C,
i want the sum to be able to pick up that inserted range to sum ranges

A1:C1
automatically

is there a way??



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Dyamic Ranges

Thanks Tom,

Is there a way to do in VB????

"Tom Ogilvy" wrote:

=SUM(INDIRECT("A"&ROW()&":"&ADDRESS(ROW(),COLUMN()-1)))

--
Regards,
Tom Ogilvy


"Andy" wrote in message
...
I was wondering if i could do this, if so how?

I have a sum that goes through the same row. Everytime i insert a column

i
want it to automatically to include that inserted range.

Example:
A B C D
1
2
3

Cell C1 is suming Ranges A1:B1. Now if i insert the column before column

C,
i want the sum to be able to pick up that inserted range to sum ranges

A1:C1
automatically

is there a way??




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Dyamic Ranges

What is in column C. Constants that represent the sum of A and B or a
formula that sums A and B.

--
Regards,
Tom Ogilvy

"Andy" wrote in message
...
Thanks Tom,

Is there a way to do in VB????

"Tom Ogilvy" wrote:

=SUM(INDIRECT("A"&ROW()&":"&ADDRESS(ROW(),COLUMN()-1)))

--
Regards,
Tom Ogilvy


"Andy" wrote in message
...
I was wondering if i could do this, if so how?

I have a sum that goes through the same row. Everytime i insert a

column
i
want it to automatically to include that inserted range.

Example:
A B C D
1
2
3

Cell C1 is suming Ranges A1:B1. Now if i insert the column before

column
C,
i want the sum to be able to pick up that inserted range to sum ranges

A1:C1
automatically

is there a way??






  #5   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Dyamic Ranges

Hi Andy,

If you're interested,

An alternative approach that's really easy to use directly in cells, or with
VBA, is using local Defined Names with relative references. For example, in
your scenario I would assign cell "C1" the name "'SheetName'!LeftCell" (minus
the quote characters) in the Name box. Then I would highlight the contents of
the "RefersTo:" box and select cell "B1". The resulting address that appears
in the RefersTo box will have "$" characters, which must be removed to make
the reference relative to C1 as one cell to the left. Now, any cell where you
use this name in a formula will reference the cell to its immediate left.

The formula you enter directly in a cell is "=SUM(A1:LeftCell)". I find this
technique much more descriptive than using the INDIRECT() function, and more
flexible.

Obviously, you can do the same for any offset reference you want. Here's
some suggestions:

LastLeft LastCell LastRight
LeftCell (Target) RightCell
NextLeft NextCell NextRight

Relative to "(Target)", you can easily see which cell is being referenced,
"(Target)" being the cell that contains the formula using the locally Defined
Name.

You can enter the formula with VBA as follows:
ActiveCell.Formula = "=SUM(A1:LeftCell)" (Be sure to include the quote
characters)

Enjoy...
GS


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
Name Ranges... Vixter Excel Worksheet Functions 10 January 25th 10 12:54 PM
how copy formula that contains ranges so ranges do not overlap Patty Excel Worksheet Functions 1 November 20th 08 04:15 PM
3D Ranges David Excel Worksheet Functions 21 June 9th 05 06:11 PM
Like 123, allow named ranges, and print named ranges WP Excel Discussion (Misc queries) 1 April 8th 05 06:07 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 07:14 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"