- 帖子
- 5923
- 主題
- 13
- 精華
- 1
- 積分
- 5986
- 點名
- 0
- 作業系統
- win10
- 軟體版本
- Office 2010
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台灣基隆
- 註冊時間
- 2010-5-1
- 最後登錄
- 2022-1-23
        
|
10#
發表於 2013-8-3 14:20
| 只看該作者
回復 9# yliu - Private Sub CommandButton1_Click()
- Dim g As Integer, E As Range, C As Range, 單號 As String, SS As String, Rng As Range
- Dim i As Integer
- With Sheets("login")
- 單號 = .ComboBox1.Value
- Set Rng = .[B9:B19]
- SS = Application.Phonetic(Rng) '結合所有序號
- End With
-
- With Sheets("final").[A:A]
- If Application.CountIf(.Cells, 單號) > 1 Then
- .Replace 單號, "=xxx", xlWhole ''Replace 方法
- With .SpecialCells(xlCellTypeFormulas, xlErrors)
- .Cells = 單號
- For Each C In .Cells ''比對到 序號 踢除 此序號
- If InStr(SS, C.Offset(, 1)) Then SS = Replace(SS, C.Offset(, 1), "") 'Replace 函數
- If SS = "" Then Exit Sub
- Next
- End With
- End If
- For Each E In Rng
- If E = "" Then Exit For
- If InStr(SS, E) Then '比對到 序號
- g = Application.CountA(.Cells) + 1 '讀取A欗有資料數的儲存格數 +1
- i = Application.CountA(Rng)
- .Cells(g, "A").Resize(1) = 單號
- .Cells(g, "B").Resize(1, 2) = E.Cells(1).Resize(1, 2).Value
- .Cells(g, "D").Resize(1, 6) = E.Cells(1, 4).Resize(1, 6).Value
- End If
- Next
- End With
- End Sub
複製代碼 |
|