Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Select random cell from defined range

Hi
I have 5 cells [range is I13:I17] each with a hyperlink to a wav file and I
would like to have a macro that randomly selects these cells to enable the
hyperlink.
Is this possible?
cheers
Tanya
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Select random cell from defined range

See if this will help any....


Mark Ivey


Dim i As Integer
Sub test()
RandomNo 'call Julian's RandomNo procedure

'change as needed
Cells(i, 9).Offset(12).Select
End Sub


' The procedure below was from the following resource
'---------------------------------------------------------------------------------------
' Procedure : RandomNo
' DateTime : 10/27/2001
' Author : Julian S.
' Website :
http://www.angelfire.com/biz7/julian...ans_macros.htm
' Purpose : For macros to generate random numbers,
' the code is takes this format -
' Int ((upperbound - lowerbound +1) * Rnd + lowerbound).
' Where the Upperbound is the largest number random number
' to be generated and Lowerbound is the lowest.
'---------------------------------------------------------------------------------------
'
Sub RandomNo()
Randomize
MyNumber = Int((5 - 1 + 1) * Rnd + 1)
'MsgBox ("The random number is ") & (MyNumber)
i = MyNumber 'added to work with the first procedure
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Select random cell from defined range

Sub ordinate()
v1 = 13
v2 = 17
j = Int(((v2 - v1 + 1) * Rnd) + v1)
Range("I" & j).Select
End Sub
--
Gary''s Student - gsnu200779


"Tanya" wrote:

Hi
I have 5 cells [range is I13:I17] each with a hyperlink to a wav file and I
would like to have a macro that randomly selects these cells to enable the
hyperlink.
Is this possible?
cheers
Tanya

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Select random cell from defined range

On Apr 13, 12:51*pm, Tanya wrote:
Hi
I have 5 cells [range is I13:I17] each with a hyperlink to a wav file and I
would like to have a macro that randomly selects these cells to enable the
hyperlink.
Is this possible?
cheers
Tanya


This code will work and follow the hyperlink:

Sub RandomLink()

Dim rngTargetCell As Range
Dim iRandomNumber As Integer

Set rngTargetCell = Nothing

Randomize
iRandomNumber = Int(5 * Rnd + 13)
Set rngTargetCell = Range("I" & iRandomNumber)

rngTargetCell.Hyperlinks(1).Follow
End Sub
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Select random cell from defined range

Thank you very much Alex,
It worked a treat.

Tanya

"Alex Simmons" wrote:

On Apr 13, 12:51 pm, Tanya wrote:
Hi
I have 5 cells [range is I13:I17] each with a hyperlink to a wav file and I
would like to have a macro that randomly selects these cells to enable the
hyperlink.
Is this possible?
cheers
Tanya


This code will work and follow the hyperlink:

Sub RandomLink()

Dim rngTargetCell As Range
Dim iRandomNumber As Integer

Set rngTargetCell = Nothing

Randomize
iRandomNumber = Int(5 * Rnd + 13)
Set rngTargetCell = Range("I" & iRandomNumber)

rngTargetCell.Hyperlinks(1).Follow
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
select and copy 100 random cells from a range in a source workbook Albie Excel Worksheet Functions 3 May 15th 07 07:54 PM
select random value in a range of cells Pete Morris Excel Discussion (Misc queries) 4 March 30th 07 09:26 PM
Select random cell SammyJJones Excel Worksheet Functions 4 November 11th 05 01:56 AM
VBA to select a defined range Shawn Excel Programming 5 July 21st 05 09:05 PM
Select a random cell < 1 Jason Morin[_3_] Excel Programming 3 April 17th 04 04:24 PM


All times are GMT +1. The time now is 11:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"