Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-20-2021, 07:12 AM
CuriousG CuriousG is offline Randbetween function embedded in a macro HELP Windows 10 Randbetween function embedded in a macro HELP Office 2016
Novice
Randbetween function embedded in a macro HELP
 
Join Date: Jan 2021
Posts: 20
CuriousG is on a distinguished road
Default Randbetween function embedded in a macro HELP

Hello everyone, I wonder if there is anyone who can help me please.



From a list of 10 names manually inserted in a spreadsheet I want to invoke a macro by pressing a button (I know how to do this bit). The macro will then randomly a number using the RANDBETWEEN function and highlight the corresponding name in the spreadsheet (this is the bit I don't know how to do).

Ideally I'd like the random selection to be relatively evenly spread across the 10 names but don't know if this is possible to control using a random function.
Attached Files
File Type: xlsm RECAP Project.xlsm (22.2 KB, 6 views)
Reply With Quote
  #2  
Old 02-21-2021, 01:51 AM
Purfleet Purfleet is offline Randbetween function embedded in a macro HELP Windows 10 Randbetween function embedded in a macro HELP Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 345
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

Try something like this

Code:
Sub Randomly_generate_a_number_between_1_and_10_inclusive()
'
' Macro1 Macro

    Range("b:b").Interior.Color = xlNone
    
    randnum = WorksheetFunction.RandBetween(1, 10)
'
    Range("D2") = randnum
    
    Range("A:A").Find(what:=randnum, LookIn:=xlValues, lookat:=xlWhole).Offset(0, 1).Interior.Color = vbYellow
       
    
End Sub
Attached Files
File Type: xlsm Copy of RECAP Project_Purfleet.xlsm (23.2 KB, 4 views)
Reply With Quote
  #3  
Old 02-21-2021, 05:32 AM
p45cal's Avatar
p45cal p45cal is offline Randbetween function embedded in a macro HELP Windows 10 Randbetween function embedded in a macro HELP Office 2019
Expert
 
Join Date: Apr 2014
Posts: 863
p45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant futurep45cal has a brilliant future
Default

Mixed messages in your file (button text) and the narrative in msg#1!
In the attached 3 buttons doing various things, each calling a one-line macro, along with some conditional formatting on the sheet. More explanations in the attached.
Attached Files
File Type: xlsm msofficeforums46516RECAP Project.xlsm (25.0 KB, 5 views)
Reply With Quote
  #4  
Old 02-21-2021, 10:48 AM
CuriousG CuriousG is offline Randbetween function embedded in a macro HELP Windows 10 Randbetween function embedded in a macro HELP Office 2016
Novice
Randbetween function embedded in a macro HELP
 
Join Date: Jan 2021
Posts: 20
CuriousG is on a distinguished road
Default

OK guys thanks very much for your help
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Randbetween function embedded in a macro HELP RANDBETWEEN question derohanes Excel 3 01-25-2019 09:38 AM
Randbetween function embedded in a macro HELP Calculating bonus in an embedded IF function Yde1203 Excel Programming 2 07-22-2018 08:24 AM
RandBetween for PowerPoint excelledsoftware PowerPoint 1 09-19-2014 11:32 PM
Randbetween function embedded in a macro HELP RandBetween Formula Help acbh Excel 1 09-12-2013 06:51 PM
Randbetween function embedded in a macro HELP word macro that reformats embedded links in a doc EricT Word VBA 7 09-12-2012 04:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:45 PM.


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