LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default Using variables in SUBTOTAL functions in Excel/VBA

ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-LineNumber]C:R[-
1]C)"

This does not work.



the reason that that doesn't work is that it hardcodes the
string 'LineNumber' into your formula, whereas the
term 'LineNumber' only means anything to your program, in
the context of your subroutine.

Use it like this:

ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-" & LineNumber
& "]C:R[-1]C)"



In that, you are entering literal strings for the parts of
the formula that are not variables, but entering the
variable into the cell formula, not the name of the
variable.

Your variable likely actually isn't a string, but I just
tried it and Excel did the conversion on it's own as shown
above.

 
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
How to dealing with functions with 30+ variables? Darius Excel Worksheet Functions 7 July 25th 08 12:52 AM
subtotal functions Louise Excel Worksheet Functions 6 February 1st 07 08:51 PM
Can I use variables for workheet name references in Excel functions? Amihai Bareket Excel Discussion (Misc queries) 1 February 4th 05 05:11 PM
Can I use variables for workheet name references in Excel functions? Amihai Bareket Excel Worksheet Functions 1 February 4th 05 05:11 PM
variables in row and cell functions zeraia Excel Programming 1 October 22nd 03 03:55 PM


All times are GMT +1. The time now is 06:23 AM.

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"