Macro Find Records that change in Column

neodjandre

Well-known Member
Joined
Nov 29, 2006
Messages
950
Office Version
  1. 2019
Platform
  1. Windows
I have a column like this:

Line1: J1
Line2: J1
Line3: J2
Line4: J2
Line5: J2
Line6: J3
Line7: J3
Line8: J4
Line9: J4
Line10: J4
Line11: J5
Line12: J5

I would like a macro to find the last occurence of each J and draw a horizontal line in my table. In the above example, a line should be drawn on "Lines" 2,5,7,10,12.

Appreciate the help.

Andrew
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
In which column are your "J" values and how many columns are in your table?
 
Last edited:
Upvote 0
You could do that with conditional formatting.

Select A2 to last row in column J
Conditional Formatting > New Rule > Use a formula
=$C2<>$C3
then select the format > Ok
 
Upvote 0
thank you Fluff - that's actually a much better solution you are suggesting ! thanks so much :)
 
Upvote 0
though I am trying to apply a thick border - and for some reason this is not supported in conditional formatting ..
 
Upvote 0
Unfortunately CF only allows a thin border for some reason.
 
Upvote 0
If you want a thick border, try
Code:
Sub neodjandre()
   Dim Cl As Range
   
   For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
      If Cl.Value <> Cl.Offset(1).Value Then
         Cl.Offset(, -2).Resize(, 10).Borders(xlEdgeBottom).Weight = xlThick
      End If
   Next Cl
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,550
Members
449,088
Latest member
davidcom

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