我正在尝试编写代码来查找一组文本(例如副总裁、总裁、总监等),并将VP、Executive或Director分别放在右侧的单元格中。经过几次尝试,我正在寻求帮助。
Sub Enter_Job_Function()
'
' This Macro is designed to take keywords in the job title column and place
' the approperate Job Function in the approperate column.
'
Dim result As String
Range("O2").Select
Range(Selection, Selection.End(xlDown)).Select
' Cells.Find(What:="Vice President", After:=ActiveCell, LookIn:=xlFormulas _
' , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
' MatchCase:=False, SearchFormat:=False).Activate
If InStr(1, ActiveSheet.Range("O2").Value, "Vice President") > 0,_
Then cell.Offset(0, 1).Value "VP"
End Sub
尝试:
On Error Resume Next
Sheet1.Cells.Find("Vice President").Offset(0, 1) = "VP"
Sheet1.Cells.Find("President", , , xlWhole).Offset(0, 1) = "Executive"
Sheet1.Cells.Find("Director").Offset(0, 1) = "Director"
On Error Goto 0
不确定您的需求,但这将找到您枚举的单词的所有第一个实例,并在其旁边的单元格上放置等效标签。