Get 3rd future value for referent text

smide

Board Regular
Joined
Dec 20, 2015
Messages
162
Office Version
  1. 2016
Platform
  1. Windows
Hello.


In columns A and B (A2:B600) I have a lists of customer names and their buying prices in columns D and E (D2:E600).
When customer name is in column A his buying price is in column D (same row of course) and when customer is in column B his bying price is in column E.


I'm trying to analyze the future buying prices for each customer, more precisely the 3rd future buying price (from referent/current one) for each customer and to place those results into columns F and G.


When name is in column A result (3rd future buying price) should be in column F and when name is in column B result should be in column G.


example (for customer Name1).


ABCDEFGH
1resultsresults
2Name132
3
4Name1825
5Name11217
6
7Name12
8Name125
9Name117
10........

<tbody>
</tbody>

results explanation: for cell A2 (Name1 first occurrence) 3rd future occurence (Name1) is in cell A7 and buying price for that 3rd future occurence is in cell D7 = 2, so result in cell F2 is equal to 2

note: just as an option (if possible) I would like also to have reverse formula (3rd past buying price for each customer)
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Smide,

Try running this code and let me know how it works for you...

Code:
Sub Macro1()


Dim C As Range


For Each C In Range("A1:B300")
    If C <> "" Then
    With Range("A" & C.Row & ":B600")
    Cells.Find(What:=C.Text, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
    Cells.FindNext(After:=ActiveCell).Activate
    Cells.FindNext(After:=ActiveCell).Activate
    Cells.FindNext(After:=ActiveCell).Activate
    ActiveCell.Offset(0, 2).Copy
    C.Offset(0, 4).PasteSpecial
    Application.CutCopyMode = False
    End With
    End If
Next


End Sub
 
Upvote 0
Unfortunately, something's wrong with this code.

It deleted my data (prices) from column E and populate it with some numbers (incorrect results)...:confused:
But thanks anyway for trying, I appreciate it.
 
Upvote 0
Try this, copied across and down.

Excel Workbook
ABCDEFG
1resultsresults
2Name132
3
4Name1825
5Name11217
6
7Name12
8Name125
9Name117
10
3rd Future
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,412
Messages
6,124,761
Members
449,187
Latest member
hermansoa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top