Question:
NEED HELP IN MS EXCEL VBA 2010. how do i make it count? and make it solve?
Jaspy02
2015-01-04 00:00:36 UTC
hi, need help in ms excel vba. im using a userform with two txtbox and a commandbutton. how do i make it count? like when i put a num at textbox 1 for example 5 then for txtbox 2 will be 20 then i hit commandbutton i want that cell a1 will be 5, then a2 will be 6, then a3 will be 7, then a4 will be 8, a5 will be 9, and i want for it to stop at 20.
at the same time i want for it to solve for its square root, in cell B, also the answer should be in 5 decimal

like A1 B1
1 1
2 1.41421
3 1.73201
and it stops at 20 and thus the answer
20 4.47213
Three answers:
garbo7441
2015-01-04 08:32:12 UTC
Here is a modification to the macro provided in your first question.



Private Sub CommandButton1_Click()

ActiveSheet.Range("A:A").ClearContents

If Me.TextBox1 = "" Or Me.TextBox2 = "" Or _

Not IsNumeric(TextBox1) Or Not IsNumeric(TextBox2) Then

TextBox1 = ""

TextBox2 = ""

Exit Sub

End If

j = Val(TextBox1)

For i = 1 To Val(TextBox2) - Val(TextBox1) + 1

ActiveSheet.Cells(i, "A").Value = j

ActiveSheet.Cells(i, "B").Value = _

Application.RoundDown((j ^ (1 / 2)), 5)

j = j + 1

Next i

End Sub



Side Note: the square root of 3 is not 1.73201, it is 1.73205
SailorDumb
2015-01-04 00:28:02 UTC
are you talking about a cell function or a VBA macro?
Jaspy02
2015-01-04 02:26:35 UTC
idk know much, but all i want is dat the control is from a userform then to the worksheet


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...