Sub changeDec()
Dim ws As Worksheet: Set ws = Sheets("data")
Dim r As Range: Set r = ws.Range("C2:C20")
Dim AR() As Variant: AR = r.Value2
For i = LBound(AR) To UBound(AR)
AR(i, 1) = Int(AR(i, 1)) + Rnd()
Next i
r.Value2 = AR
End Sub
sorry got it a bit wrong numbers are in percentage.How about this?
VBA Code:Sub changeDec() Dim ws As Worksheet: Set ws = Sheets("data") Dim r As Range: Set r = ws.Range("C2:C20") Dim AR() As Variant: AR = r.Value2 For i = LBound(AR) To UBound(AR) AR(i, 1) = Int(AR(i, 1)) + Rnd() Next i r.Value2 = AR End Sub
ADVERTISEMENT
Sub random_number()
Dim i As Double
Dim r As Double
Dim cell As Range
For Each cell In Range("c2:c20").Cells
r = cell.Value
i = Int(cell.Value)
r = r - i
r = Rnd(r)
cell.Value = i + r
Next cell
End Sub
Sub changeDec()
Dim ws As Worksheet: Set ws = Sheets("data")
Dim r As Range: Set r = ws.Range("C2:C20")
Dim AR() As Variant: AR = r.Value2
For i = LBound(AR) To UBound(AR)
AR(i, 1) = (Int(AR(i, 1) * 100) + Rnd()) / 100
Next i
r.Value2 = AR
End Sub
ADVERTISEMENT
Sub changeDec()
Dim ws As Worksheet: Set ws = Sheets("data")
Dim r As Range: Set r = ws.Range("C2:C20")
Dim i As Long
Dim AR() As Variant: AR = r.Value2
Randomize
For i = LBound(AR) To UBound(AR)
If AR(i, 1) <> "" Then
AR(i, 1) = (Int(AR(i, 1) * 100) + Rnd()) / 100
End If
Next i
r.Value2 = AR
End Sub