Excel行混合

首先,我从来没有见过这样的15年的Excel编程这样的事情。

在一个更轻的笔记,我觉得这个特殊的Excel文件是闹鬼的:P

严肃地说,我真的不明白发生了什么事情。

问题

代码(我没有写它)运行并隐藏基于条件的行。 当您单击第59行C列以外的任何单元格时,将显示它是从第58行开始的。 只在单元格C中显示正确的地址。

截图

在这里输入图像描述

我试过了什么?

  1. 首先,我认为这是一个ScreenUpdating问题,但你可以看到代码,这是排除。
  2. 我手动进入所有这些单元格从Col A到Col D,在立即窗口键入?Activecell.Row 。 我得到了58,59,58,58
  3. 检查了Google是否有人遇到过这类问题。 但找不到一个实例! 我不知道还有什么可能是这个问题。

 Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Dim i, j, k, lastrow As Long Dim finlast As Long Application.ScreenUpdating = False 'Income_Disc lastrow = Sheets("Financial_Disc1").Range("E65536").End(xlUp).Row finlast = Sheets("Financial_Disc").Range("A65536").End(xlUp).Value + 1 If Target.Column = 9 And Target.Row = 1 Then 'Unhide Rows if I1 is double clicked Sheets("Financial_Disc1").Rows("1:65536").EntireRow.Hidden = False Else If Target.Row > 7 And Target.Row < lastrow Then If Target.Column = 9 Then 'Hide Rows For j = Target.Row To lastrow If Sheets("Financial_Disc1").Range("B" & CStr(j + 1)) <> "" Then 'Hide Rows Sheets("Financial_Disc1").Range("A" & CStr(j)).EntireRow.Hidden = True Exit For Else 'Hide Rows Sheets("Financial_Disc1").Range("A" & CStr(j)).EntireRow.Hidden = True End If Next j End If End If End If Sheets("Financial_Disc1").Range("A8:A65536").ClearContents For i = 8 To lastrow If Sheets("Financial_Disc1").Range("A" & CStr(i)).EntireRow.Hidden = True Then If Sheets("Financial_Disc1").Range("B" & CStr(i)) <> "" Then Sheets("Financial_Disc1").Range("A" & CStr(i)) = "" End If Else If Sheets("Financial_Disc1").Range("B" & CStr(i)) <> "" Then Sheets("Financial_Disc1").Range("A" & CStr(i)) = finlast finlast = finlast + 1 End If End If Next i Application.ScreenUpdating = True End Sub 

杂项点

正如你可以看到这个文件有相反的列,因为它来自我在沙特阿拉伯的客户之一。

我的问题

任何人都可以看到可能是什么问题? 或者我应该简单地将它视为“稀有”错误?

请检查合并单元格的行 – 遍历它们可能导致行“移位”