Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 331
Default writing a formula using VBA

I am trying to make a macro that will write a formula to a cell. I am using
the code below but running into an issue with it.

ActiveCell.Formula =
"=SUMPRODUCT(SUBTOTAL(3,OFFSET(L6:L2000,ROW(L6:L20 00)-MIN(ROW(L6:L2000)),,1))*(L6:L2000="Yes"))"

it acts like all of it is going to work until it gets to the ="Yes" part of
the code and then it expects the first " to be the end of the formula. How
else can I get a macro to write
=SUMPRODUCT(SUBTOTAL(3,OFFSET(L6:L2000,ROW(L6:L200 0)-MIN(ROW(L6:L2000)),,1))*(L6:L2000="Yes")) into cell B2?

Thank you for your help.
Greg

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default writing a formula using VBA

Hi Greg,

For quotes qithin quotes, use two quotes

"=SUMPRODUCT(SUBTOTAL(3,OFFSET(L6:L2000,ROW(L6:L20 00)-MIN(ROW(L6:L2000)),,1))*(L6:L2000=""Yes""))"

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


"Greg" wrote in message
...
I am trying to make a macro that will write a formula to a cell. I am
using
the code below but running into an issue with it.

ActiveCell.Formula =
"=SUMPRODUCT(SUBTOTAL(3,OFFSET(L6:L2000,ROW(L6:L20 00)-MIN(ROW(L6:L2000)),,1))*(L6:L2000="Yes"))"

it acts like all of it is going to work until it gets to the ="Yes" part
of
the code and then it expects the first " to be the end of the formula.
How
else can I get a macro to write
=SUMPRODUCT(SUBTOTAL(3,OFFSET(L6:L2000,ROW(L6:L200 0)-MIN(ROW(L6:L2000)),,1))*(L6:L2000="Yes"))
into cell B2?

Thank you for your help.
Greg


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default writing a formula using VBA

HI Greg

Double the quotes around text:
...))*(L6:L2000=""Yes""))"

HTH. Best wishes Harald

"Greg" wrote in message
...
I am trying to make a macro that will write a formula to a cell. I am
using
the code below but running into an issue with it.

ActiveCell.Formula =
"=SUMPRODUCT(SUBTOTAL(3,OFFSET(L6:L2000,ROW(L6:L20 00)-MIN(ROW(L6:L2000)),,1))*(L6:L2000="Yes"))"

it acts like all of it is going to work until it gets to the ="Yes" part
of
the code and then it expects the first " to be the end of the formula.
How
else can I get a macro to write
=SUMPRODUCT(SUBTOTAL(3,OFFSET(L6:L2000,ROW(L6:L200 0)-MIN(ROW(L6:L2000)),,1))*(L6:L2000="Yes"))
into cell B2?

Thank you for your help.
Greg


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 331
Default writing a formula using VBA

Thank you both so much. I am not sure why I did not think of that. Worked
great.

Greg


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
Need help with writing formula. John1791 Excel Worksheet Functions 1 December 27th 07 01:45 PM
Writing own formula 2 dspilberg Excel Programming 3 June 26th 07 02:58 PM
Need help writing formula plz.. nparrott Excel Discussion (Misc queries) 7 February 10th 06 05:26 PM
Need Help Writing a Formula Lynn Excel Worksheet Functions 11 September 11th 05 07:51 PM
Help writing a formula Adam Excel Worksheet Functions 5 August 2nd 05 07:39 PM


All times are GMT +1. The time now is 02:15 AM.

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"