![](/img/trans.png)
[英]Find cells with same value within one column and return values from separate column of same row
[英]Search one column for string and add values to four different cells in same row
Sub test_wordisbarn()
Dim FirstAddress As String, cF As Range
ActiveSheet.Range("F1").Activate
With ActiveSheet.Range("F:F")
'First, define properly the Find method
Set cF = .Find(What:="mug", _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
'If there is a result, keep looking with FindNext method
If Not cF Is Nothing Then
FirstAddress = cF.Address
Do
'Add your value in other columns
cF.Offset(0, 1).Value = 5
cF.Offset(0, 2).Value = 10
cF.Offset(0, 3).Value = 15
Set cF = .FindNext(cF)
'Look until you find again the first result
Loop While Not cF Is Nothing And cF.Address <> FirstAddress
End If
End With
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.