Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-11-2012, 07:09 AM
JohnWilson JohnWilson is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,914
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

It needs a macro

To generate the random number use this formula:
Number =Int((highest number in range - one less that lowest number)*rnd + lowest number in range)
EXAMPLE number between 10 and 1000
Code:
Number=Int(991*rnd)+10 '991 is 1000 -9



__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #2  
Old 08-11-2012, 07:40 AM
Jamtart Jamtart is offline Randomly generate numbers, Macro? Windows 7 64bit Randomly generate numbers, Macro? Office 2010 64bit
Advanced Beginner
Randomly generate numbers, Macro?
 
Join Date: Apr 2012
Posts: 53
Jamtart is on a distinguished road
Default

Hi John, I did find this one and it works great:
Sub UpdateRandomNumber(oSh As Shape)
oSh.TextFrame.TextRange.Text = CStr(Random(12))
SlideShowWindows(1).View.GotoSlide (SlideShowWindows(1).View.Slide.SlideIndex)
End Sub

Function Random(High As Long) As Long
Randomize
Random = Int((High * Rnd) + 1)
End Function


No I need to find a way to get this randomly generated number to interact with other numbers. This is an electrical exersize and the formulas are based on Ohms law. The circuit will have 120 V applied, and two resistors in series, the reistance of one resistor is the Randomly generated number and the other I would keep at 100 ohms at this time. so the formulas/results that I would be looking to have work on the screen would be:
1. Total resistance - Randomly generated number plus 100
2. Current - 120 divided by Total resistance
3. Volt drop 1, which is the resistor having the Randoml generated number - Current times the randomly generated number
4. Volt drop 2, which is my static resistor of 100 ohms - Current time 100

I am trying to learn VBA and this would go a long way to doing that as well as a spring board to other similiar projects.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to recap data of same numbers Jasa P Word VBA 0 06-28-2012 02:41 AM
Randomly generate numbers, Macro? Formatting changing randomly Franuzz Word 1 07-14-2011 04:12 PM
black text randomly changing to white when run macro G DeBree PowerPoint 0 03-16-2011 09:23 AM
Randomly delayed emails Colinest84 Outlook 1 01-14-2011 02:32 AM
Documents Randomly Corrupting the IT Guy Word 0 02-06-2009 09:11 AM

Other Forums: Access Forums

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