我意识到这里有一些不同的类似想法。但是我需要这个简单的比较功能的帮助。
我的目标是比较两个不同的单元格,如果它们相同,请将其替换为完整的非缩写名称。
感谢您的时间!!!
IE
Sheet1 Sheet2
Column H Column A Column B
Dept Dept Department
这就是我所拥有的(是的,很简单),但单元格 H 没有更新为非缩写:
Sub updateDeptNames()
'Format user ID from the email column
Dim ws As Worksheet, ws2 As Worksheet
Dim LastRow As Long, i As Long
Dim tmpArray() As String, tempDept As String
Set ws = ActiveWorkbook.Sheets("Student_Travel_DB") '--> This is the relevant sheet
Set ws2 = ActiveWorkbook.Sheets("gokoutd") '--> This is the relevant sheet
LastRow = 1000 ''Bug finding the last row, had to hard code it
For i = 2 To LastRow 'Iterate through all the rows in the sheet
For j = 2 To 112
tempDept = ws2.Range("A" & j).Value
If ws.Range("H" & i).Value = tempDept Then
ws.Range("H" & i) = ws2.Range("B" & j).Value
End If
Next j
Next i
End Sub