I have a spreadsheet with cells that use randbetween(). At the bottom of each column there is a sum() cell for these cells. I made a macro that refreshes the values until a column's total is within a certain number range. Each time a sum cell is true to this criteria it should "paste special" the column's values to a range of cells in a blank table corresponding to it. It doesn't seem to work though. It never paste's anything and contiues to generate random values even though I see it hitting the correct numbers.
Here's the code:
Sub GEN()
Do
Calculate
If ([B8] < 40) And ([B8] > 38) Then
Range("B4:B9"). Select
Selection.Copy
ActiveSheet.Ran ge("B15:B20").P asteSpecial Paste:=xlPasteV alues
End If
Loop Until ([B8] < 40) And ([B8] > 38)
Do
Calculate
If ([C8] < 40) And ([C8] > 38) Then
Range("C4:C9"). Select
Selection.Copy
Worksheets(1).R ange("C15:C20") .PasteSpecial Paste:=xlPasteV alues
End If
Loop Until ([C8] < 40) And ([C8] > 38)
Do
Calculate
If ([D8] < 40) And ([D8] > 38) Then
Range("D4:D9"). Select
Selection.Copy
ActiveSheet.Ran ge("D15:D20").P asteSpecial Paste:=xlPasteV alues
End If
Loop Until ([D8] < 40) And ([D8] > 38)
Do
Calculate
If ([E8] < 40) And ([E8] > 38) Then
Range("E4:E9"). Select
Selection.Copy
ActiveSheet.Ran ge("E15:E:20"). PasteSpecial Paste:=xlPasteV alues
End If
Loop Until ([E8] < 40) And ([E8] > 38)
End Sub
Here's the code:
Sub GEN()
Do
Calculate
If ([B8] < 40) And ([B8] > 38) Then
Range("B4:B9"). Select
Selection.Copy
ActiveSheet.Ran ge("B15:B20").P asteSpecial Paste:=xlPasteV alues
End If
Loop Until ([B8] < 40) And ([B8] > 38)
Do
Calculate
If ([C8] < 40) And ([C8] > 38) Then
Range("C4:C9"). Select
Selection.Copy
Worksheets(1).R ange("C15:C20") .PasteSpecial Paste:=xlPasteV alues
End If
Loop Until ([C8] < 40) And ([C8] > 38)
Do
Calculate
If ([D8] < 40) And ([D8] > 38) Then
Range("D4:D9"). Select
Selection.Copy
ActiveSheet.Ran ge("D15:D20").P asteSpecial Paste:=xlPasteV alues
End If
Loop Until ([D8] < 40) And ([D8] > 38)
Do
Calculate
If ([E8] < 40) And ([E8] > 38) Then
Range("E4:E9"). Select
Selection.Copy
ActiveSheet.Ran ge("E15:E:20"). PasteSpecial Paste:=xlPasteV alues
End If
Loop Until ([E8] < 40) And ([E8] > 38)
End Sub
Comment