LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Using Relative Reference Function to apply to Range

All,

I've written a function that looks at a range of cells and adds them up
based on the Offset function. The range of cells will change based on
another defined range's contents.

What I want to be able to do is copy the function down several rows and
have that same range added via a relative reference however with the
code attached, all the cells that have the formula get updated to the
last cell that where the function was applied. I understand why my
logic isn't right but does anyone have an idea how to make this work?

Thanks for the input.

--------------

Function YTDMonths()

Dim intMonthCount As Integer, b As Integer, c As String
Dim TempSum As Double
Dim aRange

ActiveCell.Select

'Determines how far into the range to add (based on month in another
defined range)

Select Case Range("CurrentMonth")
Case Is = 38718: intMonthCount = 11
Case Is = 38749: intMonthCount = 12
Case Is = 38777: intMonthCount = 13
Case Is = 38808: intMonthCount = 14
Case Is = 38838: intMonthCount = 15
Case Is = 38869: intMonthCount = 16
Case Is = 38899: intMonthCount = 17
Case Is = 38930: intMonthCount = 18
Case Is = 38961: intMonthCount = 19
Case Is = 38991: intMonthCount = 20
Case Is = 39022: intMonthCount = 21
Case Is = 39052: intMonthCount = 22
End Select

TempSum = 0

'c = ActiveCell.Address
'Debug.Print c

For b = 11 To intMonthCount
TempSum = TempSum + ActiveCell.Offset(0, b).Value
Next

YTDMonths = TempSum
Calculate
End Function

 
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
Relative Range Reference in a sumifs formula cbotos Excel Worksheet Functions 6 April 1st 10 02:59 AM
Range of cells: Convert relative reference into absolute Igor Excel Discussion (Misc queries) 5 September 30th 08 01:16 AM
Range.FormulaArray drops relative reference ? SPaquin Excel Programming 4 September 13th 05 03:00 AM
Indirect function - relative reference Vladimir[_2_] Excel Programming 3 February 5th 04 09:05 PM
How to apply a function across a range of cells Paul Excel Programming 0 July 9th 03 10:42 PM


All times are GMT +1. The time now is 02:58 PM.

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"