• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

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
0
efarhat
Asked:
efarhat
  • 3
  • 2
1 Solution
 
efarhatAuthor Commented:
i changed:
pName = Cells(i.Row - 1, i.Column).value

still doesn't work.
0
 
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:
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now