|
- Sub 合并相同课程()
- Application.DisplayAlerts = False
- Dim i%, j%, irow%, k%
- Dim rng As Range
- irow = Range("a1000").End(xlUp).Row
- For i = 2 To 7
- k = 0
- For j = 5 To irow + 1
- If Cells(j, i) = Cells(j - 1, i) Then
- k = k + 1
- End If
- If Cells(j, i) <> Cells(j - 1, i) And k > 0 Then
- Set rng = Range(Chr(i + 64) & j - 1 - k & ":" & Chr(i + 64) & j - 1)
- rng.HorizontalAlignment = xlCenter
- rng.VerticalAlignment = xlCenter
- rng.Merge
- k = 0
- End If
- If k > 1 And Cells(j - 1, i) = "" And j = irow + 1 Then
- Set rng = Range(Chr(i + 64) & j - k & ":" & Chr(i + 64) & j - 1)
- rng.Merge
- End If
- Next j
- Next i
- Application.DisplayAlerts = True
- End Sub
复制代码
|
|