mardi 9 juin 2020

Can't work out how to run a macro within another macro

I'm very new to visual basic and have copied the following macro to run a random number generator. This works fine. But I now want to copy and paste the number generated from the cell to another cell as paste values. Then I want to generate the next number and copy and paste this new number. Basically I am trying to draw a 1st, 2nd and 3rd number and be able to show them as such after being randomly generated so that they do not change when the next number is generated. I can't work out how to put a macro that copies and pastes the number each time after running the random number generator.

This is the code I copied for the random number generator

Sub BINGO()

Dim linenumber As Integer, numpick As Integer
Dim bingonum As String

linenumber = Range("E1").Value
numpick = Range("B" & linenumber).Value
Range("B" & linenumber).ClearContents

If numpick > 90 Then
bingonum = "W " & numpick
ElseIf numpick > 80 Then
bingonum = "A " & numpick
ElseIf numpick > 70 Then
bingonum = "R " & numpick
ElseIf numpick > 60 Then
bingonum = "D " & numpick
ElseIf numpick > 50 Then
bingonum = "* " & numpick
ElseIf numpick > 40 Then
bingonum = "3 " & numpick
ElseIf numpick > 30 Then
bingonum = "5 " & numpick
ElseIf numpick > 20 Then
bingonum = "8 " & numpick
ElseIf numpick > 10 Then
bingonum = "1 " & numpick
Else
bingonum = "HCC  " & numpick
End If

Range("G5").Value = bingonum


End Sub

Can anyone help. I tried recording 3 macros to do the copy and paste and then added call macroname and did this 3 times. This did it once but then doesn't loop and repeat.

thanks




Aucun commentaire:

Enregistrer un commentaire