+ Reply to Thread
Results 1 to 2 of 2

syntax for formula in VBA

  1. #1
    Registered User
    Join Date
    11-13-2012
    Location
    Detroit
    MS-Off Ver
    Excel 2003
    Posts
    1

    syntax for formula in VBA

    I have an excel workbook that I am trying to edit. The workbook was done years ago and the person who did it is long gone. The vba code inserts a formula into values when a command button moves the values from the input part of the sheet to the record keeping part of the sheet. That is, values are put in for various items for the week. At the end of the week you push a command button that moves the week numbers to an area of the sheet that keeps weekly totals for the year and when it does that it calculate percentages on some of those numbers. Currently the formula is: =IF(C7=0,0,D7/(C7). The vba is: xlS.Cells(intRow, 5).Formula = "=IF(C" & intRow & "=0,0,D" & intRow & "/C" & intRow & ")" I want to change the formula to : =IF(C7=0,0,D7/(C7-(N7+P7))) I thought the vba would be: xlS.Cells(intRow, 5).Formula = "=IF(C" & intRow & "=0,0,D" & intRow & "/(C" & intRow & "-(N" & intRow & "+P" intRow & ")))" but this is giving an "Compile error Expected: end of statement ". Any help would be great.

  2. #2
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: syntax for formula in VBA

    Please Login or Register  to view this content.
    Missing the ampersand.
    Want to show appreciation for the help you received from a member? Give them reps by clicking the bottom left of their post!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. syntax of formula
    By cmccabe in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-10-2014, 10:06 PM
  2. Syntax Formula help
    By Kobayashi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2006, 12:30 PM
  3. Formula Syntax Help
    By Ikaabod in forum Excel General
    Replies: 2
    Last Post: 04-21-2006, 10:35 AM
  4. Formula syntax {;;;}
    By Simplefi in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  5. [SOLVED] Formula syntax {;;;}
    By Simplefi in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  6. Formula syntax {;;;}
    By Simplefi in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  7. [SOLVED] Formula syntax {;;;}
    By Simplefi in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2005, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1