lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
I want to use the value of variable s in first sub and in the second sub. I do not want to ask user to enter number of students again in the second sub. I asked user to enter number of students in sub1 and assigned this value to "s". So if user enter s=10 then I need to use the same value s=10 in sub2. Can I do that? Thank you
I want to use the value of variable s in first sub and in the second sub. I do not want to ask user to enter number of students again in the second sub. I asked user to enter number of students in sub1 and assigned this value to "s". So if user enter s=10 then I need to use the same value s=10 in sub2. Can I do that? Thank you
Code:
Dim s as integer
''''''''''''''''''''''''''''''''
Sub studentgrade()
Dim x As Integer, y As Integer
s = InputBox("number of students")
Cells(1, 2).Value = "marks"
For x = 2 To s
Cells(x, 2).Value = WorksheetFunction.RandBetween(1, 100)
Next x
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub myresult()
Dim x As Integer
For x = 2 To s
If Cells(x, 2).Value > 50 Then
Cells(x, 3).Value = "pass"
End If
Next x
End Sub