Solved

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

Posted on 2004-08-11
5
174 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
Comment Utility
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
Comment Utility
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
Comment Utility
this works: Cells(i.Row - 1, i.Column).value
0
 

Author Comment

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

Expert Comment

by:mvidas
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Vb.net Listview 9 76
MsgBox 2 36
Copy a row 12 52
Exit a vb6 apps when a calling it apps closes 15 33
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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

9 Experts available now in Live!

Get 1:1 Help Now