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

  • Home
  • SEARCH
  • 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 3990406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:29:25+00:00 2026-05-20T06:29:25+00:00

I have some cells with, for an example, this value: 5*A-2*B-4*C In other cells

  • 0

I have some cells with, for an example, this value:

5*A-2*B-4*C

In other cells I would put the values for A, B and C. I would like to make additional cell that would count the value. So, for an example, if in some cells it is written that the value of A is 2, value of B is 3 and value of C is 1, I would like an additional cell that would calculate and put the value 0 (that’s the result of 5*2-2*3-4*1). Possible variables are A, B and C, but they don’t have to be contained in every cell (e.g., some cell may be just 5*A-3*C).

Is that possible? Does anyone know how to write that function?

P.S. I can’t split manualy values in different cells because there are hundreds of them.

Thanks.

  • 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-05-20T06:29:26+00:00Added an answer on May 20, 2026 at 6:29 am

    This can be done with the VBA function EVALUTE

    simple example:

    Function ev(f As Variant, A As Range, B As Range, C As Range) As Variant
        Dim s As String
        s = f
        s = Replace(s, "A", "~A~")
        s = Replace(s, "B", "~B~")
        s = Replace(s, "C", "~C~")
    
        s = Replace(s, "~A~", A.Address)
        s = Replace(s, "~B~", B.Address)
        s = Replace(s, "~C~", B.Address)
    
        ev = Evaluate(s)
    End Function
    

    eg if your expression is in A2, and the values of A, B, C are in C2:E2

    =ev(A2,C2,D2,E2)
    

    returns the calculated value

    You would want to use a ParamArray instead of A, B, C the variable values to allow for an arbitrary number of variables.

    A slightly more complete version:

    Function ev(expr As Variant, VarNames As Range, varValues As Range) As Variant
        Dim s As String
        Dim i As Long
    
        s = expr
        For i = 1 To VarNames.Columns.Count
            s = Replace(s, VarNames.Cells(1, i), "~" & VarNames.Cells(1, i) & "~")
        Next
        For i = 1 To VarNames.Columns.Count
            s = Replace(s, "~" & VarNames.Cells(1, i) & "~", varValues.Cells(1, i).Address)
        Next
    
        ev = Evaluate(s)
    End Function
    

    Usage:

    Same data as above plus variable names in C1:E1

    =ev(A2,C1:E1,C2:E2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data. I want to go through that data and change cells
I have some classes layed out like this class A { public virtual void
I have some data structured like this in an Excel spreadsheet: A B C
I have have some code which adds new cells to a table and fills
We have some really old code that calls WebServices using behaviours (webservice.htc), and we
Problem: We have a web app that calls some web services asynchronously (from the
I have some UI in VB 2005 that looks great in XP Style, but
We have some input data that sometimes appears with &nbsp characters on the end.
I've scourged the internet for an example that would use both spring-json and annotated
I need some help tweaking this php code to print out a default value

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.