1

我正在使用下面的代码来设置过滤器并从过滤器中剪切某些数据并将其放入另一个选项卡中。

但是我有两个问题:

  1. 当我从过滤表中剪切数据(我正在使用.EntireRow.Cut)时,我在过滤器中留下了空白行。 如何在不留下空白行的情况下剪切数据?
  2. 我想要Cut过滤数据(不包括第 1 行中的标题)。我不能使用偏移量,或者.Resize因为它将我带到隐藏行(不包括在过滤器范围内)。 我该如何解决这个问题?

代码是:

Lcol = FindLastCol(gcsCombinedKycExportsSheetName)
Lrow = FindLastRow(gcsCombinedKycExportsSheetName)
Set rngToCheck = Range(Sheets(gcsCombinedKycExportsSheetName).Cells(1, 1), _
    Sheets(gcsCombinedKycExportsSheetName).Cells(Lrow, Lcol)).Rows


FieldNum = Sheets(gcsCombinedKycExportsSheetName).Cells.Find(What:=gcsSearchFund, After:=[a1], LookIn:=xlValues, _
    LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext).Column


Sheets(gcsCombinedKycExportsSheetName).Rows(1).AutoFilter


rngToCheck.AutoFilter Field:=FieldNum, Criteria1:= _
    "=*[2]*", Operator:=xlOr, Criteria2:="="


Lrow = FindLastRow(gcsCombinedKycExportsSheetName)
LrowRT = FindLastRow(gcsRemovedInvestors)


Sheets(gcsCombinedKycExportsSheetName).Range(Sheets(gcsCombinedKycExportsSheetName).Cells(1, 1), _
    Sheets(gcsCombinedKycExportsSheetName).Cells(Lrow, 1)).EntireRow.Cut Sheets(gcsRemovedInvestors).Cells(LrowRT, 1)
4

1 回答 1

1

在 Siddharth Rout 的全力支持下,我设法解决了这个问题:

我使用了以下内容:

.SpecialCells(xlCellTypeVisible)

这使我可以只选择要剪切的可见单元格。

我设置了动态范围并用于.Resize取消选择标题,所以我只剪切了我过滤的数据。

再次感谢支持。

夏兰。

于 2013-02-08T14:29:49.353 回答