Private Sub CommandButton1_Click()
Dim NumMembers As Integer
NumMembers = Cells(2, 2).Value
Dim ConCheck As Integer
Dim Con1 As Integer
Dim Con2 As Integer


For ConCheck = 1 To NumMembers


Con1 = Cells(4 + ConCheck, 12)
Con2 = Cells(4 + ConCheck, 13)


If Cells(4 + Con1, 3) = "Fixed" Then GoTo Fixed 'check if the bearing is fixed

Cells(4 + Con1, 8).Formula = (Cells(4 + ConCheck, 11) ^ 2 - (Cells(4 + Con2, 9) + Cells(4 + Con1, 9)) ^ 2) ^ 0.5 - Cells(4 + Con2, 8) 'print Con1(x)
Cells(4 + Con1, 9).Formula = (Cells(4 + ConCheck, 11) ^ 2 - (Cells(4 + Con2, 8) + Cells(4 + Con1, 8)) ^ 2) ^ 0.5 - Cells(4 + Con2, 9) 'print Con1(y)
Cells(4 + Con2, 8).Formula = (Cells(4 + ConCheck, 11) ^ 2 - (Cells(4 + Con1, 9) + Cells(4 + Con2, 9)) ^ 2) ^ 0.5 - Cells(4 + Con1, 8) 'print Con2(x)
Cells(4 + Con2, 9).Formula = (Cells(4 + ConCheck, 11) ^ 2 - (Cells(4 + Con1, 8) + Cells(4 + Con2, 8)) ^ 2) ^ 0.5 - Cells(4 + Con1, 9) 'print Con2(y)

Fixed: Next ConCheck

End Sub



This is my script I have written to attempt to input formulae into cells. The issue that I have is keep the formula in the cell instead of the value as the value changes as more equations are solved but when I put the "" marks round I obviouosly just get what is written above in the cell. I have found it difficult to explain this but basically would like to code in a way that the variables that correspond to cells become fixed to that cell when the formula prints into the cell e.g.

Cells(4 + Con1, 8).Formula = (Cells(4 + ConCheck, 11) ^ 2 - (Cells(4 + Con2, 9) + Cells(4 + Con1, 9)) ^ 2) ^ 0.5 - Cells(4 + Con2, 8)

becomes

Cells(4 + Con1, 8).Formula = "((K5) ^ 2 - (I6 + I7)) ^ 2) ^ 0.5 - H6"

so that formula stays in that cell but the VBA script can still alter the formula dependant on the variables.

hope this makes sense please help!