Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim a, b(30), x(9), y(9)
n = 1
For r = 1 To 6
For c = 1 To 4
If Cells(r, c) <> "" Then Cells(r + 7, c) = Cells(r, c)
Next c
Next r
For r = 7 To 13
For c = 1 To 4
a = Cells(r, c)
If a = "" Then Exit For
k = 0
For i = 1 To n
If a = b(i) Then
Cells(r, c).Interior.ColorIndex = 6
k = 1
Else
k = 0
End If
Next i
If k = 0 Then b(n) = a
n = n + 1
Next c
Next r
For r = 7 To 13
For c = 1 To 4
If Cells(r, c) <> "" Then Cells(r + 7, c) = Cells(r, c)
If Cells(r, c).Interior.ColorIndex = 6 Then Cells(r + 7, c).Interior.ColorIndex = 6
Next c
Next r
For r = 14 To 20
For c = 1 To 4
If Cells(r, c) <> "" And Cells(r, c).Interior.ColorIndex = 6 Then
Cells(r, c) = ""
Cells(r, c).Interior.ColorIndex = xlNone
End If
Next c
Next r
For r = 14 To 20
c2 = 1
For c = 1 To 4
If Cells(r, c) <> "" Then
Cells(r + 7, c2) = Cells(r, c)
c2 = c2 + 1
End If
Next c
Next r
For r = 21 To 27
n = 1
For c = 1 To 4
If Cells(r, c) <> "" Then
x(n) = Cells(r, c)
y(n) = Len(x(c))
n = n + 1
End If
Next c
n = n - 1
For i = 1 To n - 1
For j = i + 1 To n
If y(j) < y(i) Then
m = y(j)
y(j) = y(i)
y(i) = m
m = x(j)
x(j) = x(i)
x(i) = m
End If
Next j
Next i
For c = 1 To n
Cells(r, c) = x(c)
Next c
Next r
End Sub
追问楼上的哥哥 这个怎么用的哦!继续上图说明这问题!
追答菜单:工具——宏——VB编辑器,把代码复制到这里
只有原始数据的表格中,任意点不同单元格就出现几个步骤了
这问题不是一样的吗?