Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-21-2017, 06:26 PM
physicsphilosopher physicsphilosopher is offline randomize numbers. help me defeat plagiarism! Windows 10 randomize numbers. help me defeat plagiarism! Office 2016
Novice
randomize numbers. help me defeat plagiarism!
 
Join Date: Mar 2017
Posts: 5
physicsphilosopher is on a distinguished road
Default randomize numbers. help me defeat plagiarism!

Hey guys, this is my first post here! I'm a high school physics teacher in my 2nd year and i'm getting tired of the amount of copying that is happening in my Honors Physics class. I'd like to make a VBA macro that will randomize numbers on every copy i print for tests/worksheets. I use word 2016 at home and work.



Something where i could type a problem like this
"Billy dropped a rock off a X meter high cliff. The rock has a mass of Y kilograms"

And then when i print it i could print up 130 copies and word would automatically insert a random number within a designated range on each copy for the X and Y above. Below is what i have so far in code but i don't think it'll do the trick. Any advice? Thanks!!!

Option Explicit

Public Function RandomNumber(Lowest As Long, Highest As Long, _
Optional Decimals As Integer)

If IsMissing(Decimals) Or Decimals = 0 Then
Randomize
RandomNumber = Int((Highest + 1 - Lowest) * Rnd + Lowest)
Else
Randomize
RandomNumber = Round((Highest - Lowest) * Rnd + Lowest, Decimals)
End If
End Function

Sub RNG1to10()

Dim rn1 As Double
Dim text As Double

rn1 = RandomNumber(1, 10, 0)

Selection.TypeText text:=rn1

End Sub
Reply With Quote
 

Tags
word 2016



Other Forums: Access Forums

All times are GMT -7. The time now is 09:35 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