I have the following snipet in Excel 2013/VBA. The code is a very simple random cell/row generator which then displays the output in a text box. In the snippet below Excel/Vba is adding a space between A and the random numebr for example:
"A 14"
where the expected out put was
"A14"
I've gotten around this using the Replace() function, however I'm wondering why this behaviour occurs i the first place. Is it to do with the Str() function?
Private Sub btnRetrieve_Click()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("CenRaw")
Dim k As Long
Dim selectedRow As String
k = sh.Range("A2", sh.Range("A2").End(xlDown)).Rows.Count
aRandNum = Int((k - 2) * Rnd + 2)
selectedRow = Replace("A" & Str(aRandNum), " ", "")
tbOne.Text = selectedRow
selectedRow = vbNullString
End Sub