我希望在符合countif條件時獲取有關獲取單元地址或行的幫助。我覺得我只是想念一些簡單的東西。Countif後的返回單元地址/行
這裏是什麼,我至今一大塊:
Wb2.Activate
Wb2.Sheets.Add(After:=Wb2.Sheets(Wb2.Sheets.Count)).Name = "Report"
With Wb2.Sheets("From")
Set myRange = .Range("F2:G" & lastRow)
End With
With Wb2.Sheets("Weekly_Stat")
Set forComp = Wb2.Sheets("Weekly_Stat").Range("D2:E" & lastRow2)
End With
Sheets("From").Activate
For Each item In myRange.Rows
With item
.Select
myCount = item.Row
myBool = False
foundIt = Application.CountIfs(forComp.Columns(1), .Cells(1).Value, forComp.Columns(2), .Cells(2).Value)
If foundIt Then myBool = True
If myBool = True Then
myStr = forComp.Row
Wb2.Sheets("Report").Cells(myCount, 10).Value = "Found"
MsgBox myStr
Else
Wb2.Sheets("Report").Cells(myCount, 10).Value = "Not Found"
End If
End With
Next item
在代碼中,我試圖讓forComp發現項目的行,但我慘遭失敗。
我想知道如何獲得在「Weekly_Stat」中找到的匹配行號。
目前,我只能確定「來自」表中的數據是否在「Weekly_Stat」中找到。我在新的「報告」表格中放置了「找到」和「未找到」的列。
我想要做的是:
- 檢查數據在Weekly_Stat發現,在報告的地方結果(完成)
- 發現,在Weekly_Stat存在數據後,我需要得到的地址/ row
- 我將使用行/地址從Weekly_Stat的同一行中的下一列中獲取另一個數據。
我試圖尋找我的困境,但我無法找到解決方案。我可能會使用錯誤的關鍵字進行搜索,所以如果已經提出了這個問題,我很抱歉。任何幫助將不勝感激。非常感謝。
它看起來像你想返回的行數字爲兩列匹配。有更簡單的方法來做到這一點。 – Jeeped