Unknown variables

sinanvarann

New Member
Joined
Dec 3, 2020
Messages
12
Office Version
  1. 2016
Platform
  1. Windows
Hey guys I have 2 coordinate point (1,4) and (2,6) i want to find their equation. In math its 2x+2. But I couldnt calculate it with vba codes.
Equation formul is (y2-y1)/(x2-x1)= (y-y1)/(x-x1) and we are pulling y from there. So (6-4)/(2-1)=(y-6)/(x-2) then y= 2x+2.
I want to learn how can I define unknown variables by integer.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Excel already has formulas for Slope and Intercept using known x's and y's. You can use those in VBA with Application.WorksheetFunction.Slope and Application.WorkseetFunction.Intercept.

So your VBA might look like:
VBA Code:
Sub CalculateSlopeIntercept()
    Dim slope As Double
    Dim intercept As Double
    slope = Application.WorksheetFunction.slope(RangeofYs, RangeofXs)
    intercept = Application.WorksheetFunction.intercept(RangeofYs, RangeofXs)
    ...
End Sub
 
Upvote 0
Excel already has formulas for Slope and Intercept using known x's and y's. You can use those in VBA with Application.WorksheetFunction.Slope and Application.WorkseetFunction.Intercept.

So your VBA might look like:
VBA Code:
Sub CalculateSlopeIntercept()
    Dim slope As Double
    Dim intercept As Double
    slope = Application.WorksheetFunction.slope(RangeofYs, RangeofXs)
    intercept = Application.WorksheetFunction.intercept(RangeofYs, RangeofXs)
    ...
End Sub
Dude I need with easy way of that. Without any ready formulas. This is my friend's assignment but we shouldn't use any complicated code. We have to define x like integer. And we have to calculate anything with it. Like when x is unknown variable and coefficient any integer like 3. Its should be 3x. When coefficient is 0 its should be 0*x = 0 not 0x. Thanks anyway
 
Upvote 0
Dude I need with easy way of that. Without any ready formulas. This is my friend's assignment but we shouldn't use any complicated code. We have to define x like integer. And we have to calculate anything with it. Like when x is unknown variable and coefficient any integer like 3. Its should be 3x. When coefficient is 0 its should be 0*x = 0 not 0x. Thanks any
 

Attachments

  • shot.jpg
    shot.jpg
    147.9 KB · Views: 10
Upvote 0
So you're given a series of points as xy coordinates. What do you need? Your image indicates you just need to output an equation as a string "y=mx+b", but your post above the image makes it sound like you need to mathematically solve those equations in excel too. What exactly do you need?
 
Upvote 0
I have 2 coordinate point (1,4) and (2,6) i want to find their equation. In math its 2x+2.
That is only true if you are assuming it can only be a linear equation.
You could certainly have a lot of other equation possibilities if it is not restricted to linear equations, and can include things like parabolas, hyperbolas, etc.

Here is an interesting link of how someone did it using just formulas: How to find the equation of a line in MS Excel - Quora
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,874
Members
449,056
Latest member
ruhulaminappu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top