想像列表要長得多...有沒有辦法用 C 列中的適當名稱/ID 替換 A 和 B 中的單元格? 「適當的名稱」是 C 列中的內容(符合名稱)。這是最終結果是的,複製/貼上可以,但是當整個內容有 5000 長且 C 列的順序不完美時,需要花費很多時間。
答案1
使用 vba,您可以透過這種方式取代尋找的值 調整範圍以指向替換值所在的位置以及您正在尋找的項目的範圍
Sub substituteLookedUp()
Dim myStr As String
Dim matchDbl As Double
Dim Rng As Range
Set Rng = Range("C1:C10")
For Each cell In Range("a1:b12")
If cell <> "" Then
myStr = Mid(cell, WorksheetFunction.Find(" ", cell) + 1, Len(cell) - WorksheetFunction.Find(" ", cell)) & "_" & Left(cell, WorksheetFunction.Find(" ", cell) - 1) & "*"
matchDbl = WorksheetFunction.Match(myStr, Rng, 0)
newStr = Range("C" & matchDbl)
Else: newStr = ""
End If
cell.Value = newStr
Next
結束子