Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2013, 02:29 PM
macropod's Avatar
macropod macropod is offline Filling cells with random numbers using loops? (VBA) Windows 7 64bit Filling cells with random numbers using loops? (VBA) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,362
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


There is no need to select anything. Also, in one place your code refers to 'randoms', but then uses a different name (object) to output the value. Such inconsistencies can lead to serious problems in a more complex macro. Try:
Code:
Sub Randoms()
Dim Rng As Range
For Each Rng In Range("A1:F20")
  Rng.Value = Rnd()
Next
End Sub
PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to fill a cell with random numbers to do calculations? zanat0s Excel 1 06-13-2011 10:33 AM
Filling cells with random numbers using loops? (VBA) filling multiple cells whislt using Filter VinceO Excel 1 05-09-2011 06:38 AM
Display Random Numbers as Transition greenbutton PowerPoint 0 03-09-2011 04:43 PM
Filling cells with random numbers using loops? (VBA) Powerpoint loops, but not to beginning imeister PowerPoint 1 02-02-2011 02:05 PM
loops within presentations supateach PowerPoint 1 11-23-2010 04:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:10 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft