UrbanPro
true

Learn Microsoft Excel Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

VBA Tip: Print Random Numbers In A Selected Range

Karthik Dale
25/07/2017 0 0

Let’s say you want to print some random numbers in a selected range then you can use below Macro.

Sub Print_Randomnumbers()

Dim myrng As Range

For Each myrng In Selection

    myrng.Value = Application.WorksheetFunction.Int(Rnd * 1000)

Next myrng

End Sub

How it works?

  1. It's a for each loop which loops through each cell in the selection.
  2. VBA function Rnd populate random number from 0 to 1.
  3. If you want to print numbers up to the range of 1000 then multiply Rnd with 1000.
  4. . Int function pulls the integer value from Rnd*1000.

 

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

VBA Tip: Repeating Emp Names N number of times using 4 different loops
Hi All,This is a requirement from one of our student and here we are posting the question along with solution (this can be achieved using 4 different loops). In Column “J” there are few employee...


How to add bullets Point in MS-EXCEL
There is no direct option to add bullets in EXCEL. So we can create the bullets by the following steps: 1. Select the range where you want to apply the bullets.2. go to formate cell ==> Custom Formate.3....

My Experience on Recruitment for Data Analyst role.
Hi All, I want to share my experience here and why I chose to take up classes on Advanced excel. This is not technical lesson but a motivation to improve your skills. I was leading Data Analyst team...

Why Option Explicit is Required in the VBA Editor
Hi Folks,Do you know Excel VBA Editor has functionality where you don't need to declare a variable in memory (DIM).But what will happen if you write a program without declaring a variable nothing happens?Then...
X

Looking for Microsoft Excel Training Classes?

The best tutors for Microsoft Excel Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Microsoft Excel Training with the Best Tutors

The best Tutors for Microsoft Excel Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more