Hi
Try this
In Column A type Rand()
Fill down for several rows for each place you want to eat
In column B put the Places to eat
Then do this macro
Dim EndRow
EndRow = Range("B65536").End(xlUp).Address
Range("A1:" & EndRow).Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
MsgBox (Range("B1").Value)
End Sub
Hope this helps
Jacob
Thanks!! When I run the macro it always returns the restaurant in cell B1.
Thanks!! When I run the macro it always returns the restaurant in cell B1. Did I do something wrong? How can it randomly pick a restaurant?
Judy:
Try this:
Sub Eatery(Colm)
Randomize Timer
Range("A1") = Range(Colm & Int((Range(Colm &
200).End(xlUp).Row - 2) * Rnd) + 2)
End Sub
Sub Restaurant()
Call Eatery("A")
End Sub
Sub FastFood()
Call Eatery("B")
End Sub
Additional notes: The 2 lines that start Range("A1")... are to be on the same line of code. Put the restaurants in column A starting on row 2. Put the Fast Food places in column B starting on row 2. The formula allows you to list about 200 of each. If you need more, increase the number 200 in the code to whatever you need. Create 2 macro buttons on the sheet, lable 1 as Restaurant and assign the Restaurant macro to it. The other button is for fast food. Put the buttons to the right of cell A1 as that is where the selection will be shown.
Hope this helps. Call me for the 25th anniversary.
Tom
Judy,
While not exactly meeting your specifications, the following will be a little simpler to implement (no Userform required):
Sub WhereToEat()
Dim LastRow As Long
Dim RestaurantRow As Long
Dim EatingPlace As String
MsgBox "Would you like to find out where to have dinner?", vbOKOnly, "Marriage Saving Restuarant Selector"
LastRow = Cells(65536, 1).End(xlUp).Row
Randomize
RestaurantRow = Int((LastRow - 1 + 1) * Rnd + 1)
EatingPlace = Cells(RestaurantRow, 1).Value
MsgBox "I've decided you should eat at " & Chr(13) & Chr(9) & EatingPlace
End Sub
All that's required is that you list your choices in column A (starting at A1). You can then put a button on the buttonbar to call the macro, or put the guts of it in the workbook open event and opening the "Restaurant" workbook will start the macro. Whichever you like.
The simplification is that you don't get to chose the type of restaurant. Of course if your listing is heavily weight toward one type, then that type would be expected to come up more often.
enjoy
Re: Thanks!! When I run the macro it always returns the restaurant in cell B1.
It is Random, everytime there will be a different restaurant in B1.
Jacob
While not exactly meeting your specifications, the following will be a little simpler to implement (no Userform required):
No contest here - just find the nearest Argentine restaurant and wallow in Argentine beef and wine!!
At least someone is paying attention 'round here! LOL
Stephen,
Not many folks would pick up on that. I haven't been yet, but it is my intention to one day spend some time, right around this time of the year, casting a dry fly by day and partaking of the local fare by night.
take care
No contest here - just find the nearest Argentine restaurant and wallow in Argentine beef and wine!!