在表单转储中,我有一个表格形式的jobId和名称。现在我试图在Sheet1中粘贴那些与同一个人相对应的jobId,但Sheet1中的名称存在于一行中(如标题)。我还编写了代码(最后在评论中)来搜索这些名称(硬编码)。但现在我对整合这些代码感到困惑。请帮忙!
以下是代码:
Sub Dump()
Dim names(5) As Variant
names(0) = "Subashini"
names(1) = "Chaitra"
names(2) = "Shailaja"
names(3) = "Praveen"
names(4) = "Aritra"
names(5) = "Anitha"
Dim myCol As Long, i As Variant, lRow As Long, j As Long, teamName As String, jobId As String, trimJobId As Long
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Dump")
j = 2
lRow = sh.Range("E2").End(xlDown).Row
'Loop to get jobId from Dump
For j = j To lRow
teamName = Worksheets("Dump").Cells(j, 5).Value
If InStr(teamName, "Shailaja") Or InStr(teamName, "Aritra") Or InStr(teamName, "Subashini") Or InStr(teamName, "Chaitra") Or InStr(teamName, "Praveen") Or InStr(teamName, "Anitha") Then
jobId = Worksheets("Dump").Cells(j, 2).Value
trimJobId = Val(Right(jobId, 5))
MsgBox trimJobId
End If
Next
''''''''''''''''''''''
'Start of sheet1 code'
'''''''''''''''''''''
For Each i In names
myCol = Worksheets("Sheet1").Cells(1, 1).EntireRow.Find(What:=i, LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
MsgBox myCol
Next
'For Each i In names
' myCol = Worksheets("Sheet1").Cells(1, 1).EntireRow.Find(What:=i, LookIn:=xlValues, LookAt:=xlWhole, _
' SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column
'Next
End Sub