Hi,
Sorry if this question is abit to "simple" to answor, but im extremly new at this - so if someone has time to help i would be very thankful!
OBS :Code below.
What i want to do is to press a button that randomly chooses a "restaurang" from a list (thats on another sheet) and puts it in a cell (on the current sheet). All in the same excel file, just diffrent sheets. So in the sheet with a list of "restaurangs" theres a.. list which it should choose from.
Below is the code. And under i explain what the problem is.
Sub RandomPlace_Click()
Dim ListCount As Integer, num
Dim RandomNumber As Integer
Dim rng As Range
Set rng = Sheets("Rådata-Restaurang").Range("B3:B20")
ListCount = rng.Count
RandomNumber = Int(ListCount * Rnd + 1)
ActiveSheet.Range("B11").Select
ActiveSheet.Range("B11").Value = ActiveCell.Offset(RandomNumber - 1, 0).Value
End Sub
I believe that, since i didnt make the code. that the "set rng" doesnt understand that i want to set the range in another sheet since now it randomly picks a cell between b3 and b20 in the CURRENT sheet and puts it in B11, instead of picking the ones from the OTHER sheet.
Any ideas :/ ? Would be extremly greatful!
Bookmarks