Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to do check for factors in formulas?

I need help creating a function.

The goal is to parse formulas from cells A1 to A5 and find the values
of each factor.
Example:
A1 - "A+B=CD"
A2 - "C+D+E=A"

*Notice the double digit in the first formula.
In this example the macro needs to parse these two rows and find the
values for A,B,C,D and E that satisfy the two formulas.

The idea behind this function is to be able to type simple formulas in
several rows and have the macro calculate whatever the different
factors are that satisfy all the formulas.


Any help would be appreciated on how to do this.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to do check for factors in formulas?

On Dec 15, 9:44*pm, " wrote:
I need help creating a function.

The goal is to parse formulas from cells A1 to A5 and find the values
of each factor.
Example:
A1 - "A+B=CD"
A2 - "C+D+E=A"

*Notice the double digit in the first formula.
In this example the macro needs to parse these two rows and find the
values for A,B,C,D and E that satisfy the two formulas.

The idea behind this function is to be able to type simple formulas in
several rows and have the macro calculate whatever the different
factors are that satisfy all the formulas.

Any help would be appreciated on how to do this.


Any help how I could reference the factors into variables?
That is my major hurdle.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default How to do check for factors in formulas?

... find the values for A,B,C,D and E that satisfy the two formulas.

Hi. I may be wrong, but at the basic level, you will have two
equations, with 6 variables (if 'CD' is a variable.)
There would be an unlimited number of solutions.

= = = = = = = = = =
Dana DeLouis



On 12/15/09 8:44 PM, wrote:
I need help creating a function.

The goal is to parse formulas from cells A1 to A5 and find the values
of each factor.
Example:
A1 - "A+B=CD"
A2 - "C+D+E=A"

*Notice the double digit in the first formula.
In this example the macro needs to parse these two rows and find the
values for A,B,C,D and E that satisfy the two formulas.

The idea behind this function is to be able to type simple formulas in
several rows and have the macro calculate whatever the different
factors are that satisfy all the formulas.


Any help would be appreciated on how to do this.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to do check for factors in formulas?

Possibly,
But I intend to limit the range to 1 to 9 for example.
'CD' would not be a variable per se because it is in fact 'C' and 'D'
combined together.
So if A+B=CD then the 'C' in C+D+E=A will be the same as the 'C' in
'CD'.

So how do I assign variables to the factors and use them?

On Dec 18, 12:01*am, Dana DeLouis wrote:
* ... find the values for A,B,C,D and E that satisfy the two formulas.

Hi. *I may be wrong, but at the basic level, you will have two
equations, with 6 variables (if 'CD' is a variable.)
There would be an unlimited number of solutions.

= = = = = = = = = =
Dana DeLouis

On 12/15/09 8:44 PM, wrote:



I need help creating a function.


The goal is to parse formulas from cells A1 to A5 and find the values
of each factor.
Example:
A1 - "A+B=CD"
A2 - "C+D+E=A"


*Notice the double digit in the first formula.
In this example the macro needs to parse these two rows and find the
values for A,B,C,D and E that satisfy the two formulas.


The idea behind this function is to be able to type simple formulas in
several rows and have the macro calculate whatever the different
factors are that satisfy all the formulas.


Any help would be appreciated on how to do this.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default How to do check for factors in formulas?

So how do I assign variables to the factors and use them?

Hi. If I understand the question correctly, you extract a string, and
want to assign a value to this string.
One way that comes to mind might be to use a Dictionary Object.
The 'Key' would be the string variable, and the item the desired value.
It could work for simple things, but it might be messy with 9 equations,
and 9 unknowns. Hopefully, someone will have a better idea.

= = = = =
Dana DeLouis


On 12/21/09 8:14 PM, wrote:
Possibly,
But I intend to limit the range to 1 to 9 for example.
'CD' would not be a variable per se because it is in fact 'C' and 'D'
combined together.
So if A+B=CD then the 'C' in C+D+E=A will be the same as the 'C' in
'CD'.

So how do I assign variables to the factors and use them?

On Dec 18, 12:01 am, Dana wrote:
... find the values for A,B,C,D and E that satisfy the two formulas.


Hi. I may be wrong, but at the basic level, you will have two
equations, with 6 variables (if 'CD' is a variable.)
There would be an unlimited number of solutions.

= = = = = = = = = =
Dana DeLouis

On 12/15/09 8:44 PM, wrote:



I need help creating a function.


The goal is to parse formulas from cells A1 to A5 and find the values
of each factor.
Example:
A1 - "A+B=CD"
A2 - "C+D+E=A"


*Notice the double digit in the first formula.
In this example the macro needs to parse these two rows and find the
values for A,B,C,D and E that satisfy the two formulas.


The idea behind this function is to be able to type simple formulas in
several rows and have the macro calculate whatever the different
factors are that satisfy all the formulas.


Any help would be appreciated on how to do this.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to do check for factors in formulas?

Heres what I got so far:
I cant use the dictionary object, excel gives me some kind of error
and I cant make modifications so its out of the question,
I thought of maybe using arrays, made some spaghetti code to extract
the factors from formulas but now I dont know how to use it. :)

The simple formulas are entered on Column "F" starting on cell 2.
Use something like "ab*c=ghc" as test formula.
The sub SOLVE is empty right now and thats what needs to be filled. :)
Heres the code:

Dim factor() As String 'Factor letters
Dim FactorN() As Integer 'number for the factor letter
Dim FormulasN() As Integer ' how many factors per formula
Dim FactorUN() As Integer 'how many unique factors per formula per
line
Dim NFormula As Integer 'number of formulas to deal with
Dim TotalFactors As Integer 'Total number of factors


Sub start()

Call ParseFormulas
FactorCount = 1
startfactors = 1
For a = 1 To NFormula
If a = 1 Then
startfactors = 1
Else
startfactors = startfactors + FactorUN(a - 1)
End If ' a=1
Call solve(startfactors, FactorUN(a))

Next a

End Sub

Sub ParseFormulas()
TotalFactors = 0
checkrow = 2
countfactor = 1
startcount = Sheets("sheet1").Range("g2").Value
ReDim factor(9)
ReDim FactorN(9)
ReDim FormulasN(1)
ReDim FactorUN(1)
FormulaCount = 1

Do While Sheets("sheet1").Range(CStr("f" & checkrow)).Value < ""
ReDim Preserve FormulasN(checkrow - 1)
tempstring = UCase(Sheets("sheet1").Range(CStr("f" & checkrow)).Value)

lentempstring = Len(tempstring)
For a = 1 To lentempstring
aa = Mid(tempstring, a, 1)
If Asc(aa) 64 Then
FormulasN(checkrow - 1) = FormulasN(checkrow - 1) + 1
If countfactor = 1 Then
factor(countfactor) = aa
FactorN(countfactor) = startcount
FactorUN(checkrow - 1) = 1
countfactor = countfactor + 1

Else
b = countfactor - 1
flag = True
Do While b 0
If factor(b) < aa Then
b = b - 1
Else
flag = False
Exit Do
End If 'factor(b)<aa
Loop
If flag = True Then
factor(countfactor) = aa
FactorN(countfactor) = startcount
countfactor = countfactor + 1
FactorUN(checkrow - 1) = FactorUN(checkrow - 1) + 1
If countfactor 9 Then
ReDim Preserve factor(countfactor)
ReDim Preserve FactorN(countfactor)
End If ' countfactor9
End If 'flag=true
End If 'countfactor=1
End If 'Asc(aa) 64
Next a
ReDim Preserve FactorUN(checkrow)
checkrow = checkrow + 1
Loop
NFormula = checkrow - 2
TotalFactors = countfactor - 1

For a = 1 To checkrow - 2
Sheets("sheet1").Range(CStr("i" & a)).Value = FormulasN(a)
Sheets("sheet1").Range(CStr("k" & a)).Value = FactorUN(a)
Next a
Sheets("sheet1").Range("j1").Value = NFormulas
For a = 1 To countfactor
Sheets("sheet1").Range(CStr("j" & a)).Value = factor(a)
Next a
Sheets("sheet1").Range("l1").Value = NFormula
End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default How to do check for factors in formulas?

Any help would be appreciated.
This is an interesting challenge.
Cheers
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
Look up with 2 factors AMC Excel Worksheet Functions 1 March 26th 09 04:55 AM
if senerios with 2 factors Tacklemom Excel Discussion (Misc queries) 1 March 20th 09 08:39 PM
more factors needed for an SP UDF Bob Phillips Excel Programming 0 December 28th 06 06:11 PM
Multiply one value by many factors ghofferbert Excel Worksheet Functions 2 October 13th 05 12:22 AM
Seasonal factors Dam Excel Programming 0 April 21st 05 11:46 AM


All times are GMT +1. The time now is 10: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"