First and Last value with offset.

Luke777

Board Regular
Joined
Aug 10, 2020
Messages
243
Office Version
  1. 365
Platform
  1. Windows
Hi all

Below is my data

12blueorange
12greenlamp
12chickensheep
12yellowepsilon
4gurudoor
4switchbar
4tokenisland
8parkcoal
8snowplug
9numbersalt
9gorgeear


I'm looking for a simple way to get the first entry in column B and last entry in column C for any given reference in column A

so for "12" the results would be "blue" and "epsilon", which I would like to be displayed in E1 and F1 followed by the results of "4" in E2 and F2.

The last part isn't a strict requirement - by that I mean, if the result of 4 ends up being displayed in E5 and F5, that's fine, I can deal with the blanks easily enough :)

For a bit extra context, I have a tiny bit of code that finds the unique entries in column A (below) and I was imagining combining it with the range.offset function - but I'm afraid this has defeated me

VBA Code:
Public Sub EN()

ActiveSheet.Range("A1:A65536").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=ActiveSheet.Range("D1"), Unique:=True
 
 
End Sub

If the results of this code in D can be used as a reference point for the offset and some sort of loop, that would be useful lol. I should also note that if this bit of code is at all useful, then what I said about the blanks above is no longer relevant :)

Hopefully this all made sense.

Thanks all!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I am not sure I understand the requirement. Is this what you mean ?

Book2
ABCDEF
112blueorangeblueepsilon4
212greenlamp
312chickensheep
412yellowepsilon
54gurudoor
64switchbar
74tokenisland
88parkcoal
98snowplug
109numbersalt
119gorgeear
Sheet1
Cell Formulas
RangeFormula
D1D1=VLOOKUP(A1,$A$1:$C$11,2,FALSE)
E1E1=LOOKUP(2,1/($A$1:$A$11=A1),$C$1:$C$11)
F1F1=COUNTIF($A$1:$A$11,A1)
 
Upvote 0

Forum statistics

Threads
1,214,542
Messages
6,120,116
Members
448,945
Latest member
Vmanchoppy

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