
Sub showRandomWord()
Dim ws As Worksheet
Dim stRow As Long, endRow As Long, dataCol As Long
Dim dispRow As Long, dispCol As Long
Dim i As Long
Dim y As Variant
Dim x As Variant
Dim yStep As Integer
Set ws = Sheets("GREEN_Camp")
i = Range("E3")
y = Range("E4")
x = i - y
z = 0
stRow = 8
dataCol = 3
dispRow = 8 + x - 1
dispCol = 5
With ws
If Range("E4").Value < Range("E3").Value Then
endRow = .Cells(.Rows.Count, dataCol).End(xlUp).Row
.Cells(dispRow, dispCol).Value = _
.Cells(Application.RandBetween(stRow, endRow), dataCol).Value
End If
End With
End Sub
Sub showRandomWord()
Dim ws As Worksheet
Dim stRow As Long, endRow As Long, dataCol As Long
Dim dispRow As Long, dispCol As Long
Dim i As Long
Dim y As Variant
Dim x As Variant
Set ws = Sheets("GREEN_Camp")
i = Range("E3")
y = Range("E4")
x = i - y
z = 0
stRow = 8
dataCol = 3
dispRow = 8 + x - 1
dispCol = 5
With ws
If Range("E4").Value < Range("E3").Value Then
endRow = .Cells(.Rows.Count, dataCol).End(xlUp).Row
.Cells(dispRow, dispCol).Value = _
.Cells(Application.RandBetween(stRow, endRow), dataCol).Value
End If
End With
End Sub
|
Sub showRandomWord()
Dim ws As Worksheet
Dim stRow As Long, endRow As Long, dataCol As Long
Dim dispRow As Long, dispCol As Long
Dim i As Long
Dim y As Variant
Dim x As Variant
Dim yStep As Integer
Set ws = Sheets("GREEN_Camp")
i = Range("E3")
'''''''' variabile a ciclo for
Dim xx As Long
For xx = 1 To i
y = Range("E4")
x = i - y
Z = 0
stRow = 8
dataCol = 3
dispRow = 8 + x - 1
dispCol = 5
With ws
If Range("E4").Value < Range("E3").Value Then
endRow = .Cells(.Rows.Count, dataCol).End(xlUp).Row
.Cells(dispRow, dispCol).Value = _
.Cells(Application.RandBetween(stRow, endRow), dataCol).Value
End If
End With
Next xx
End Sub
|
