Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
BCS BCS is offline
external usenet poster
 
Posts: 4
Default Need Help w/ SUM Formula Syntax

I have a macro that inserts a SUM formula for a range of cells on a single
row. Here's what I have so far:

Dim RegionRange as String

RegionRange = Range(Cells(NextBlankRow, FIRSTREGION_COL),
Cells(NextBlankRow, TotalCol - 1)).Address
Worksheets(DATASHEET).Cells(NextBlankRow, TotalCol).Formula = "=Sum(" &
RegionRange & ")"

The value of variable RegionRange ends up being something like
"$B$49:$H$49", which is correct but I don't want an absolute reference.
Everything works fine, but I would prefer to have a relative reference like
"B49:H49" instead. There's the possibility that the user could insert a
column in which case the SUM using the absolute reference won't pick up the
new data.

Thanks,

Barry


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need Help w/ SUM Formula Syntax

RegionRange = Range(Cells(NextBlankRow, FIRSTREGION_COL),
Cells(NextBlankRow, TotalCol - 1)).Address(False,False)

--

HTH

RP
(remove nothere from the email address if mailing direct)


"BCS" wrote in message
m...
I have a macro that inserts a SUM formula for a range of cells on a single
row. Here's what I have so far:

Dim RegionRange as String

RegionRange = Range(Cells(NextBlankRow, FIRSTREGION_COL),
Cells(NextBlankRow, TotalCol - 1)).Address
Worksheets(DATASHEET).Cells(NextBlankRow, TotalCol).Formula = "=Sum(" &
RegionRange & ")"

The value of variable RegionRange ends up being something like
"$B$49:$H$49", which is correct but I don't want an absolute reference.
Everything works fine, but I would prefer to have a relative reference

like
"B49:H49" instead. There's the possibility that the user could insert a
column in which case the SUM using the absolute reference won't pick up

the
new data.

Thanks,

Barry




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
formula syntax. Babs Excel Discussion (Misc queries) 3 February 23rd 08 10:56 AM
Formula Syntax John Johns Excel Worksheet Functions 1 February 18th 06 12:18 PM
VBA Formula Syntax Dale[_14_] Excel Programming 5 November 29th 04 08:18 PM
Formula Syntax Todd Huttenstine Excel Programming 3 June 11th 04 05:14 PM
Formula Syntax Alexey E. Kolmyk Excel Programming 1 October 7th 03 12:41 PM


All times are GMT +1. The time now is 08:37 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"