Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


How to pull an Excel cell value into a variable in a Macro


How to pull an Excel cell value into a variable in a Macro

Author
Message
VB_Rene
VB_Rene
Forum God
Forum God (545 reputation)Forum God (545 reputation)Forum God (545 reputation)Forum God (545 reputation)Forum God (545 reputation)Forum God (545 reputation)Forum God (545 reputation)Forum God (545 reputation)Forum God (545 reputation)

Group: Forum Members
Posts: 1, Visits: 2
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

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search