I'm trying to obtain the text/value of two selected cells (not necessarily adjacent) in an Excel sheet.
How can I reference the cells in the selection via some sort of "indexing"?
xxx = selection.cells(1).value
yyyy = selection.cells(2).value
doesn't do it, since the second refers to the cell exactly below that is referenced by the first.
I have this code to iterate the selected cells, but I don't like it, as I cannot reference the cells by address or index. usr1 and usr2 are to have the names of the two "users" selected in the sheet.
Dim usr1, usr2 As String
Dim usrs(1) As String
Dim myCell As Range
Dim uIndex As Integer
Worksheets("Tests").Activate
uIndex = 0
For Each myCell In Selection
usrs(uIndex) = myCell.Value
uIndex = uIndex + 1
Next
usr1 = usrs(0)
usr2 = usrs(1)
How can I reference the different selected cells directly?