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: 10
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, 2 views)
Reply With Quote
  #2  
Old 02-21-2021, 01:51 AM
Purfleet Purfleet is online now 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: 262
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, 0 views)
Reply With Quote
  #3  
Old 02-21-2021, 05:32 AM
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: 464
p45cal is a name known to allp45cal is a name known to allp45cal is a name known to allp45cal is a name known to allp45cal is a name known to allp45cal is a name known to all
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, 1 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: 10
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 - Senior Forums

All times are GMT -7. The time now is 11:25 AM.


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