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

Datedif() Function
Purpose: This function calculates difference between two dates. it can show the result in days, months and years. Syntax: =datedif(start_date,end_date,"unit") start_date This is earliest...

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

Hidden Gems of MS Excel - Reapply Filter
Q) How does Reapply help? Or, when could I use Reapply?A) e.g. Please refer following screenshot: You are Analysing a Dataset.You have applied Filter on Date Column, to focus on April month entries.You...

Today WE LEARN a excel formula like UPPER FUNCTION
Here we are using upper case formula, these formula are used in advanced excel. A B C 1 Hansraj HANSRAJ =upper(TEXT) =UPPER(B1) 2 lakir LAKIR =UPPER(B2) 3 Seema SEEMA =UPPER(B3) 4 Mansi MANSI =UPPER(B4) 5 jyoti JYOTI =UPPER(B5) 6 mahima MAHIMA =UPPER(B6) 7 shashi SHASHI =UPPER(B7) ...

What is save workspace?
Its an option in excel that help you to save a shortcut in particular place (may be your desktop). When you double click to open this shortcut it opens all the related excel files together from different...
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