单元格边框不是“find”

我有一张如下所示的表格:

在这里输入图像说明

我想要一个VBA代码来查找客户编号并“测量”它所在的块有多大。

例:
8887有两列。
8736有两列。
8602有一列。

我使用range.find来查找客户编号,然后在列中循环一个偏移量以查找“块”结束的位置。
该块在不同的内部颜色时结束,在单元格中写入另一个客户或者find单元格边界。

Set C = rng.Find(Search, _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not C Is Nothing Then FirstAddress = C.Address FirstColor = C.Interior.Color Do ' If it's just one cell width (column CJ) If C.Borders(xlEdgeRight).LineStyle <> xlNone Then Platser = Platser & Mid(C.Address, 2) & "," 'append the locations string Else Platser = Platser & Mid(C.Address, 2) & "," 'append the locations string i = 1 ' This is the loop that is causing problem. 'As I see it it should stop at i=1 but it keeps looping While C.Offset(0, i).Interior.Color = FirstColor And _ C.Offset(0, i).Value = "" And _ C.Offset(0, i).Borders(xlEdgeRight).LineStyle <> xlNone 'append the locations string Platser = Platser & Mid(C.Offset(0, i).Address, 2) & "," i = i + 1 Wend End If ' here I find the next cell with the same value, ' but this has nothing to do with the problem. Set C = rng.Find(Search, _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ after:=C, _ MatchCase:=False) Loop While Not C Is Nothing And FirstAddress <> C.Address 

在这个代码后,我的单元格地址获得第3行的数字。
上面的代码的输出是:

364,363,362,361,360,359,358,357,356,354,354

所以它find值8736,但它没有看到应该停止循环的单元格边界。
什么可能导致这种行为?

 While C.Offset(0, i).Interior.Color = FirstColor And _ C.Offset(0, i).Value = "" And _ C.Offset(0, i).Borders(xlEdgeRight).LineStyle <> xlNone 

应该

 While C.Offset(0, i).Interior.Color = FirstColor And _ C.Offset(0, i).Value = "" And _ C.Offset(0, i).Borders(xlEdgeRight).LineStyle = xlNone