Place Group thick border- If two or more cells contains same value

aayaanmayank

Board Regular
Joined
Jul 20, 2018
Messages
157
Hi Can anyone please help - I have to place a thick border in the entire row based on values in Column "A" until two or more cells contains the same value. if cell A2 & A3 have the same value so i have to place a thick border which will show that these rows have same values.

[TABLE="width: 293"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD] ID[/TD]
[TD]First_Assignment[/TD]
[TD] Company name[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]WERT133026660L[/TD]
[TD]Data Quality[/TD]
[TD]DFGH[/TD]
[/TR]
[TR]
[TD]WERT133026660L[/TD]
[TD]Data Quality[/TD]
[TD]DFGH[/TD]
[/TR]
[TR]
[TD]GHIKL134344566L[/TD]
[TD]Data Quality[/TD]
[TD]OLKJNBV[/TD]
[/TR]
[TR]
[TD]GHIKL134344566L[/TD]
[TD]Data Quality[/TD]
[TD]OLKJNBV[/TD]
[/TR]
[TR]
[TD]GHIKL134344566L[/TD]
[TD]Data Quality[/TD]
[TD]OLKJNBV[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
@aayaanmayank,

Is there any reason it needs to be a think border around the entire row?
If not, then you could use the "duplicate values" conditional formatting rule on column A...
Then perhaps go Conditional Formatting --> Manage Rules to edit the formatting style if you want.

Otherwise, gimme a sec and I will see if I can figure this one out real quick for ya.
 
Upvote 0
Hey aayaanmayank,


You can try the below macro

Code:
Sub ThickBoarder()

Dim lRow As Long, txt As String

lRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row

For x = lRow To 2 Step -1
    txt = Cells(x, 1).Offset(-1, 0)
    If Cells(x, 1) <> txt Then
        Rows(x).Borders(xlEdgeTop).Weight = xlThick
    End If
Next

End Sub
 
Last edited:
Upvote 0
Upvote 0
Hi Brother Yes, it worked perfectly the way I want however it not including the last row. if below ID is at the end so it not drawing border.[TABLE="width: 96"]
<colgroup><col></colgroup><tbody>[TR]
[TD]GHIKL134344566L[/TD]
[/TR]
[TR]
[TD]GHIKL134344566L[/TD]
[/TR]
[TR]
[TD]GHIKL134344566L[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Ok, I have changed the order now, try the updated code below

Code:
Sub ThickBorder()

Dim lRow As Long, txt As String
lRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row

For x = 2 To lRow
    txt = Cells(x, 1).Offset(1, 0)
    If Cells(x, 1) <> txt Then Rows(x).Borders(xlEdgeBottom).Weight = xlThick
Next

End Sub
 
Upvote 0
Got most of it working pretty easy by following the instructions on the other website.
2ljpc0n.png


Unfortunately, you cannot use Conditional Formatting to do a thick border: www.excelforum.com/excel-formulas-and-functions/543056-conditional-formatting-thick-border.html
This means the only possible way to do a thick border would be to put the thick borders on every row, then use conditional formatting to replace it with no borders.
Unfortunately, I'm not certain that it can be done the way I believe you were requesting it.
This is about the closest I got:
xm26gn.png


Possible exception: I know practically NOTHING about VBA code, so it may be doable that way and I just do not know how to do it.

Hope the highlighting or thin bordering works well enough for ya. If not, definitely post a reply here and I'm sure someone else will try to chime in for ya.
 
Upvote 0
Hi buddy it not abt thick border.. i need which create one border for both the cell if duplicate ...my data is in order so every thing is lined up correctly.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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