Merged Cells and Border Color

James_Latimer

Active Member
Joined
Jan 20, 2009
Messages
415
Win 10 / Excel 2016

Hi all,

I'm having an issue with some code whereby i seem to be unable to detect the border color of merged cells. I'm using the following code:

I'm looping through each range (Rng) in Worksheet.UsedRange but the first IF statement always returns 0.

Code:
If Rng.MergeCells = True Then
     If Rng.MergeArea.Borders.Color = oldColor Then
          Rng.MergeArea.Borders.Color = newColor
     End If
Else
     If Rng.Borders.Color = oldColor Then
          Rng.Borders.Color = newColor
     End If
End If

The non-merged cells work fine but i cant get the merged cells to detect a border color of anything other than 0. oldColor and newColor are set to data type Long.

Any assistance would be sincerely appreciated. I have tried googling on the interwebs but i couldn't find a solution.

Thanks in advance!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
For some reason i couldnt get the .Color property of merged cell borders. I had to specify xlEdgeTop, xlEdgeBottom, xlEdgeLeft and xlEdgeRight separately for this to return what i expected.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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