提问人:HummBird 提问时间:10/6/2023 更新时间:10/6/2023 访问量:13
删除重复值并重新排列数据,不带空白行
Delete duplicate value and rearrange the data with out blank row
问:
我正在尝试清除重复值并重新排列从(A17 到 C30)
到 (EA1 到 EC30) 开始的数据集。
我无法添加过滤器或删除该行。只有复制和粘贴是我访问 excel 标准 2021 的唯一选项
。
我尝试了下面的代码。很难重新安排。我不想删除任何行和过滤器,因为我在其他单元格中填充了仪表板值。
Sub ClearRowValues()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
' Set the worksheet where your data is located
Set ws = ThisWorkbook.Sheets("INPUT")
' Find the last row in column A with data
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' Loop through rows from the bottom to the top
For i = lastRow To 17 Step -1 ' Start from the second last row and move upwards
If ws.Cells(i, 1).Value = ws.Cells(i - 1, 1).Value Then
' If the current Doc. No. is the same as the previous row, clear the current row
ws.Cells(i, 1).ClearContents
ws.Cells(i, 2).ClearContents
ws.Cells(i, 3).ClearContents
End If
Next i
End Sub
寻求您的帮助。请
答: 暂无答案
评论