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

Dget-Extract From A Database A Single Record That Matches The Condition We Specify
Syntax: DGET(Database, Field, Criteria) The DGET function syntax has the following arguments: Database Required: The range of cells that makes up the list or database. A database is a list of related...
D

Daniel I

1 0
0

Excel Macros Training
The Next Level Technologies Excel Learning...Read & Share....Happy Learnings Record Macro (Automating day to day activity reports) -> Choose Record Macro in the Code group of the Developer...
N

Next Level Technologies

0 0
0

VBA Function -
Using FORMAT Function in VBA we can modify the format of Numbers, Dates, Times & String. Syntax: FORMAT(expression, format, , ) 1. Formatting "Numbers" using FORMAT function in VBA SUB Format_Numbers() MsgBox...

Macro Recording
G

Gagan G.

0 0
0

An Introduction to Business Intelligence Concepts
Looking for a Business Intelligence (BI) solution for your company can be intimidating. BI uses its own special terminology and the database design concepts can be difficult to grasp. So where do you...
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