Hi. I'm new to VBA. I simply need to code the following triple nested for/next loops with the objective of solving 1 equation with 3 unknowns (a diophantine equation) as a macro in an Excel Workbook. (1)How do I assign the variable, TargetLength, to the value inside an excel workbook cell ? (2)Also, how do I print the output to another cell in the same workbook? I'm new to VBA, so I'm sure there are many mistakes here. Any pointers/corrections would be great! Thank you.
Sub LengthCalculator(TargetLength)
dim t as integer
Let t = TargetLength
For x = 0 to t
For y = 0 to t
For z = 0 to t
CalculatedLength = 5*x + 1.5*y + 0.5*z
If CalculatedLength = TargetLength Then
Print "this --->" & x,y,z
Else If CalculatedLength - TargetLength < 3 Then
Print a,b,c,y
Next x
Next y
Next z
End Sub
|