此表有6列,其中B列是A列的答案 这是一个多项选择题,在c,d,e,f列中有四个选项
我希望B柱不受影响>在B1中搜索并从C1 D1 E1和F1中删除任何找到的结果。然后排序,只有c1 d1和e1存在,f1被删除
像,
A1的问题的正确答案在B1和c1中。我希望删除C1并对第1行中的其余单元格进行排序,以便d1(爱的诗人)移动到c1,e1移动到d1,f1移动到e1
类似地,
a2问题的正确答案是在b2细胞和e2细胞中
我希望删除e2的数据,并将f2的数据移到e2
由于
答案 0 :(得分:0)
这应该为你做。
Sub TableExample()
Dim lastrow As Long
Dim address As String
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
Dim r As Range: Set r = .Range("A1", "A" & lastrow)
End With
For Each cell In r.Cells
For i = 1 To 4
If cell.Offset(0, 1).Value = cell.Offset(0, 1 + i).Value Then
address = cell.Offset(0, 1 + i).address(0, 0)
Exit For
Else
address = "0"
End If
Next
If address <> "0" Then
Dim rr As Range: Set rr = ActiveSheet.Range(address)
For i = 1 To 4
rr.Value = rr.Offset(0, 1).Value
Set rr = rr.Offset(0, 1)
Next
End If
Next
End Sub