Help with changing a Macro

M

Mike Rogers

Good evening:

I have the following macro that "Sloth" was good enough to help me with and
now I need a little change. This now needs to generate these random numbers
in the same place when a button is used. What do I change to make the new
set always appear in the range of M17:M50

Sub Macro1()
Dim myCell As Range
For Each myCell In Selection.Cells
myCell.FormulaR1C1 = "=TEXT(ROUND(10000*RAND(),0),""0000"")"
Next myCell
Selection.Copy
Selection.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False

End Sub

Thank you very much!!!

Mike Rogers
 
N

Neil

Mike,

Adding a line at the start of oyur macro will do the trick

Sub Macro1()
ActiveSheet.Range("M17:M50").Select
Dim myCell As Range
For Each myCell In Selection.Cells
myCell.FormulaR1C1 = "=TEXT(ROUND(10000*RAND(),0),""0000"")"
Next myCell
Selection.Copy
Selection.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False

End Sub

HTH


Neil
www.nwarwick.co.uk
 
Top