Solved

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

Posted on 2004-08-11
5
175 Views
Last Modified: 2011-09-20
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
Comment
Question by:efarhat
  • 3
  • 2
5 Comments
 

Author Comment

by:efarhat
ID: 11775971
i changed:
pName = Cells(i.Row - 1, i.Column).value

still doesn't work.
0
 
LVL 35

Accepted Solution

by:
mvidas earned 25 total points
ID: 11776003
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
 

Author Comment

by:efarhat
ID: 11776279
this works: Cells(i.Row - 1, i.Column).value
0
 

Author Comment

by:efarhat
ID: 11776283
i'll give you the pts anyway, since i can't give them to myself.
0
 
LVL 35

Expert Comment

by:mvidas
ID: 11776381
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Specify ip address in my connection string for sas 2 54
VB error "Type mismatch" 2 50
Visual Basic Excel Formatting error 4 83
VB6 - Convert HH:MM into Decimal 8 51
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now