在excel中需要协助以下查询,这是senarior
description version type Expected output
1-Upgrade Kit 165737 A B
7668A CPU UPGRADE 165737 B B
ASSY,PCB,P2MB,VME, 165737 B B
UPGRADE,EPROM 165737 B B
KIT,7668A CPU UPGRADE 165738 B B
1-Upgrade Kit 165738 A B
1-Upgrade Kit 165739 A C
KIT,7668A CPU UPGRADE 165739 C C
KIT,7668A CPU UPGRADE 165739 C C
正如您看到前四行的版本号相同,但是当描述中包含字符串"升级工具包时,类型会发生变化"。如果我们有相同的版本,我们可以从其他行获取类型描述为"升级套件"
答案 0 :(得分:0)
如果我理解你的问题,这应该可以解决问题。
我查看所有'说明',当找到“升级套件”时,它会查找相同的版本号并相应地更改类型。
Sub ChangeVersion()
Dim rCell As Range
Dim i As Integer
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Dim DescriptRng As Range
Set DescriptRng = Range(Cells(2, 1), Cells(Rows.Count, 1).End(xlUp))
For Each rCell In DescriptRng
If rCell = "1-Upgrade Kit" Then
For i = 2 To LastRow
If Cells(i, 2) = Cells(rCell.Row, 2) And Cells(i, 1) <> "1-Upgrade Kit" Then
Cells(rCell.Row, 3) = Cells(i, 3)
End If
Next i
End If
Next rCell
End Sub
告诉我你是否对他好。