Help with changing a Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top