- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 90
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-4-14
               
|
5#
發表於 2013-2-4 15:43
| 只看該作者
回復 4# jcchiang - Sub ex()
-
- Dim Rng As Range, a, b As Range, c As Range
-
- With Sheet2
- r = 2
- Do Until .Cells(r, 1) = ""
- a = .Cells(r, 1)
- With Sheet1
- Set c = Nothing
- For Each b In .Range(.[A2], .[A65536].End(xlUp))
- If b = a Then
- If c Is Nothing Then
- Set c = b.MergeArea.Resize(, 6)
- Else
- Set c = Union(c, b.MergeArea.Resize(, 6))
- End If
- End If
- Next
- If Not c Is Nothing Then
- If Rng Is Nothing Then
- Set Rng = c
- Else
- Set Rng = Union(Rng, c)
- End If
- End If
- End With
- r = r + 1
- Loop
- End With
- With Sheet3
- .UsedRange.Offset(1).Clear
- Rng.Copy .[A2]
- End With
- End Sub
複製代碼 |
|