Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Variable within a formula

I am trying to replace the number portion of a cell reference with the
results of another formula. I can't seem to get it to work.

This is the formula I started with:
=SUM(WO!J2:J5679)

But instead of the 5679, I want to use the result of the following formula:

=ROWS(WO!qry_WO)-1

where qry_WO is a named range on the WO sheet.

I can do this using a macro, but would prefer to do it on the worksheet.

Is this even possible?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,856
Default Variable within a formula

Try this:

=SUM(INDIRECT("WO!J2:J"&ROWS(WO!qry_WO)-1))

Hope this helps.

Pete

On Aug 20, 11:04 pm, Tom Melosi <Tom
wrote:
I am trying to replace the number portion of a cell reference with the
results of another formula. I can't seem to get it to work.

This is the formula I started with:
=SUM(WO!J2:J5679)

But instead of the 5679, I want to use the result of the following formula:

=ROWS(WO!qry_WO)-1

where qry_WO is a named range on the WO sheet.

I can do this using a macro, but would prefer to do it on the worksheet.

Is this even possible?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Variable within a formula

Thank you Pete, that is exactly what I was looking for!

"Pete_UK" wrote:

Try this:

=SUM(INDIRECT("WO!J2:J"&ROWS(WO!qry_WO)-1))

Hope this helps.

Pete

On Aug 20, 11:04 pm, Tom Melosi <Tom
wrote:
I am trying to replace the number portion of a cell reference with the
results of another formula. I can't seem to get it to work.

This is the formula I started with:
=SUM(WO!J2:J5679)

But instead of the 5679, I want to use the result of the following formula:

=ROWS(WO!qry_WO)-1

where qry_WO is a named range on the WO sheet.

I can do this using a macro, but would prefer to do it on the worksheet.

Is this even possible?




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,856
Default Variable within a formula

Thanks for feeding back, Tom - glad to be of help.

Pete

On Aug 20, 11:14 pm, Tom Melosi
wrote:
Thank you Pete, that is exactly what I was looking for!



"Pete_UK" wrote:
Try this:


=SUM(INDIRECT("WO!J2:J"&ROWS(WO!qry_WO)-1))


Hope this helps.


Pete


On Aug 20, 11:04 pm, Tom Melosi <Tom
wrote:
I am trying to replace the number portion of a cell reference with the
results of another formula. I can't seem to get it to work.


This is the formula I started with:
=SUM(WO!J2:J5679)


But instead of the 5679, I want to use the result of the following formula:


=ROWS(WO!qry_WO)-1


where qry_WO is a named range on the WO sheet.


I can do this using a macro, but would prefer to do it on the worksheet.


Is this even possible?- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Variable within a formula

"Pete_UK" wrote...
Try this:

=SUM(INDIRECT("WO!J2:J"&ROWS(WO!qry_WO)-1))

....

Or eliminate the volatile INDIRECT call by using

=SUM(WO!J2:INDEX(WO!$J:$J,ROWS(WO!qry_WO)-1))

which has the added benefit that if rows were added above row 2 or columns
inserted or deleted to the left of col J in the WO worksheet, the
nonvolatile formula wouldn't need to be revised.




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
variable substitution in a formula NHRunner Excel Discussion (Misc queries) 5 May 11th 07 01:56 PM
Using a variable in a formula [email protected] Excel Discussion (Misc queries) 1 December 29th 06 11:46 AM
Using a variable in a VBA formula Colin Vicary Excel Discussion (Misc queries) 3 November 8th 05 11:39 AM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Using a second variable within a formula... Ed Anton Excel Discussion (Misc queries) 2 February 18th 05 11:51 AM


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