Referencing Cells in a Selected Row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to obtain the value in several cells from a row selected by the user.
What is the syntax that I should use to pull the values from the selected
row?

Dim sel As Range
Set sel = Application.Selection
sel.Cells(sel.row,1)
 
....or if you know what columns you are looking for:

MyValue = Cells(Selection.Row, 1)

etc.
 
Found the problem, I was thinking that the row number in the worksheet would
correspond to the row number in the selection which it does not. Since I
limited the number of rows that can be selected using sel.rows.count to
reference a cell the syntax would be sel.cells(1, [cell number])
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top