EASY ?: How to get the previous row value in a Range? Range.Previous??

How do i get the previous row in a range?  i need pname to equal the previous row's value so i can check it against sTrader.    

   j = 1
    With Worksheets("study").Range("C36:C234")
        For Each i In .Cells
            sTrader = takeCaptionAfter(CStr(i.value), 2)
            pName = Cells(Selection.Row + 1, Selection.Column).value
           
            If InStr(sTrader, "MEMBER_CAPTION") > 0 Then
                tmpStr = sTrader
            Else
                If CStr(sTrader) <> CStr(pName) Then
                    newTrader = True
                    Arow = 3 + j
                End If
                Worksheets("report").Range("A" & j + 3).value = sTrader
                j = j + 1
            End If
           
        Next
efarhatAsked:
Who is Participating?
 
mvidasCommented:
Hi efarhat,

If you're trying to get the value of the cell above each "i" then

pName = i.Offset(-1,0).Value    

should do it.
Matt
0
 
efarhatAuthor Commented:
i changed:
pName = Cells(i.Row - 1, i.Column).value

still doesn't work.
0
 
efarhatAuthor Commented:
this works: Cells(i.Row - 1, i.Column).value
0
 
efarhatAuthor Commented:
i'll give you the pts anyway, since i can't give them to myself.
0
 
mvidasCommented:
Thanks, though you could have had it closed/refunded. With i being a cell (as defined by your for loop), it works the same as mine anyways (just longer)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.