It has been a while since I've coded in Visual Basic, so I forgot much of what I knew when working with MS Excel. I am actually coding within the developer tab of MS Excel 2007.
I have an existing workbook that contains a sheet called "MySheet". In this sheet is a range of cells with text values, and the cells rangefrom A1:A10. I would like to click a button and select the text from any random cell within this range. The text would then be displayed in a message box. Here is what I have so far. This definitely doesn't work though. Any help please? Thanks!
Private Sub myButton_Click()
Dim xl As New Excel.Application
Dim xlsheet As Excel.Worksheet
Dim xlwbook As Excel.Workbook
Dim myCell As Range
Dim rndText As String
Dim rndIndex as Integer
rndIndex = **random number...not sure how**
rndText = ""
xlsheet = xl.Workbook.Sheets("MySheet")
myCell = xlsheet.Cells(rndIndex, 1)
rndText = myCell.Value
MsgBox (rndText)
End Sub