0

## Excel 如何找到所有符合相同排序的欄位，並傳回下一欄位的值？

ccutmis iT邦高手 8 級 ‧ 2019-06-25 13:10:29 檢舉

### 1 個回答

1
Neish
iT邦研究生 1 級 ‧ 2019-06-25 13:18:26

VBA解法參考如下

``````Sub Forum()

Dim i As Integer
Dim b_end As Integer
Dim c_start As Integer

---B欄倒數第三個
b_end = Range("B1").End(xlDown).Row - 2

For i = 2 To b_end

If Range("B" & i) = Range("A2") And _
Range("B" & i + 1) = Range("A3") And _
Range("B" & i + 2) = Range("A4") Then

---找C欄空白的地方(要放值的地方)
c_start = Columns("C").Find("").Row

Range("C" & c_start) = Range("B" & i + 3)

End If

Next

End Sub
``````

ccenjor iT邦新手 4 級 ‧ 2019-06-27 18:16:03 檢舉

``````Sub Forum()

Dim i As Long
Dim b_end As Long
Dim c_start As Integer

'B欄倒數第6個
b_end = Range("B1").End(xlDown).Row - 5

For i = 2 To b_end

If Range("B" & i) = Range("A2") And _
Range("B" & i + 1) = Range("A3") And _
Range("B" & i + 2) = Range("A4") And _
Range("B" & i + 3) = Range("A5") And _
Range("B" & i + 4) = Range("A6") And _
Range("B" & i + 5) = Range("A7") Then

'找C欄空白的地方(要放值的地方)
c_start = Columns("C").Find("").Row

Range("C" & c_start) = Range("B" & i + 6)

End If

Next

End Sub
``````