Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8196001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:19:52+00:00 2026-06-07T05:19:52+00:00

From within code, based on particular criteria, I am trying to assign a formula

  • 0

From within code, based on particular criteria, I am trying to assign a formula to a particular cell. See code

        For l = 8 To lEND
        lPriorNum = .Range("N" & l)
        If lPriorNum = 1 Then
            sFormula = "=ROUND(IF(AND(N" & l & "=1,K" & l & "=0),O" & l & _
            "/100*M" & l & ",(IF(AND(N" & l & "=1,K" & l & "<>0,K" & l & _
            "<M" & l & "),K" & l & ",M" & l & "))),2)"
        Else
            sFormula = "=ROUND(IF(P" & l & "=0,0,(IF(AND(N" & l + 1 & _
            "<>1,K" & l + 1 & "<>0,M" & l + 1 & ">R" & l + 1 & _
            "),K" & l + 1 & ",(IF(AND(N" & l + 1 & "<>1,K" & l + 1 & _
            "<>0,P" & l & ">0,P" & l & "<K" & l + 1 & "),+P" & l & _
            ",(IF(AND(N" & l + 1 & "<>1,K" & l + 1 & "=0,P" & l & _
            "<=0),0,(IF(O" & l + 1 & "/100*SUM(M" & l + 1 & "-L" & l & _
            ")>M" & l + 1 & ",0,(IF(O" & l + 1 & "/100*SUM(M" & l + 1 & _
            "-R" & l & ")<M" & l + 1 & ",O" & l + 1 & "/100*SUM(M" & l + 1 & _
            "-R" & l & "),(IF(M" & l + 1 & "<=R" & l + 1 & ",IF(P" & l + 1 & _
            "-K" & l + 1 & "<0,0,+M" & l + 1 & "-K" & l + 1 & ")))))))))))))),2)"
        End If            
        .Range("L" & l).Select
        Selection.NumberFormat = "0.00"
        ActiveCell.Formula = sFormula
        Selection.NumberFormat = "0.00"
        ' Total Payout Available
        sFormula = Range("Tot_Pay_Avail").Formula
        .Range("P" & l).Select
        Selection.NumberFormat = "0.00"
        ActiveCell.Formula = sFormula
        Selection.NumberFormat = "0.00"
        ' Final Dist Running Bal
        sFormula = Range("Final_Dist_RB").Formula
        .Range("Q" & l).Select
        Selection.NumberFormat = "0.00"
        ActiveCell.Formula = sFormula
        Selection.NumberFormat = "0.00"
        sFormula = Range("Payout_Amt_Sum").Formula
        .Range("R" & l).Select
        Selection.NumberFormat = "0.00"
        ActiveCell.Formula = sFormula
        Selection.NumberFormat = "0.00"

        sFormula = vbNullString
    Next l

When the lPriorNum = 1, the code to populate L whatever works fine. When the lPriorNum is not 1, the following is the formula that is in sFormula and this does not work. I get the 1004 error:

=ROUND(IF(P9=0,0,(IF(AND(N10<>1,K10<>0,M10>R10),K10,(IF(AND(N10<>1,K10<>0,P9>0,P91,K10=0,P9<=0),0,(IF(O10/100*SUM(M10-L9)>M10,0,(IF(O10/100*SUM(M10-R9)

I’ve been told this formula as it’s written will only work in Excel 2010 and I am testing in 2007, however, 2010 users are getting the same error when they test this. What might be the issue with this formula or the way the syntax is written? The cell on the spreadsheet is formatted as number with no commas and 2 decimals. I’ve looked through some of the postings here and other websites but I think my question might be more specific than I might find in other postings…

Thanks in advance for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:19:54+00:00Added an answer on June 7, 2026 at 5:19 am

    you need to create a new workbook in the 2007 version. Pasting the formula =ROUND(IF(P9=0,0,(IF(AND(N10<>1,K10<>0,M10>R10),K10,(IF(AND(N10<>1,K10<>0,P9>0,P9<K10),+P9,(IF(AND(N10<>1,K10=0,P9<=0),0,(IF(O10/100*SUM(M10-L9)>M10,0,(IF(O10/100*SUM(M10-R9)<M10,O10/100*SUM(M10-R9),(IF(M10<=R10,IF(P10-K10<0,0,M10-K10)))))))))))))),2) into excel 2007 works with no errors.

    Pasting the same formula into a 97-2003 .xls file gives me the Too many levels of nesting error. note that a converted file will give the same issues

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to check the validity of a particular 'stand-alone' code file from within
I am trying to run the following code from within Eclipse: Process process =
This is the code from the class within which I am trying to reference
I'm writing a web based code editor for Django projects. From within the editor
I'm calling some JavaScript from within my PHP code, but I want the second
I need to run an external application from within my Java code. I can
I want insert a custom snippet into an XML file from code within an
I need to work with assets in my assets folder from within C/C++ code.
This code is run from within a subclass of UITableViewCell CALayer* greenLayer = [CALayer
In the following code, I have verified that connecting to a URL from within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.