Find the last matching activecell value in cells below and then select.

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have a code that would already select the first D or N depending on what shift it is at work.
I would like a code that can then find the last cell value that matches the activecell value in column B but searches from the activecell downwards.

Example:
D
N
D
N - This is the activecell
N
N
N - I would like a code that would select this row in column B instead.
D
N
D

Any help would be appreciated.

Thanks
Dan
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Why select that cell? There is a cell further down which contains N.
 
Upvote 0
Hi,
I need it to be that cell because it is on the same shift as the first D or N of that block of D's or N's.

The last N of my example would be the following night shift.
 
Upvote 0
VBA Code:
Sub v()
Dim c As Range: Set c = ActiveCell
Dim i&: i = 2
Do While c(i) = c.Value
    i = i + 1
Loop
c(i - 1).Select
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

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