most
Board Regular
- Joined
- Feb 22, 2011
- Messages
- 107
- Office Version
- 365
- 2019
- Platform
- Windows
- Mobile
This works fine, but I rather not use .Select
So I thought this would work, but it doesn't.
Neither does this.
The result of both are that the values are not updated.
The purpose of the script is the find all values from F25:F33 in F13:F22 and update G25:G33 with value from H13:H22.
Code:
Range("F13:F22").Select
For Each c In Range("F25:F33").Cells
If Not IsEmpty(c.Value) Then
Set FoundCell = Selection.Find(What:=c.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not FoundCell Is Nothing Then c.Offset(0, 1).Value = FoundCell.Offset(0, 2).Value + c.Offset(0, 1).Value
End If
Next c
So I thought this would work, but it doesn't.
Code:
With Range("F13:F22")
For Each c In Range("F25:F33").Cells
If Not IsEmpty(c.Value) Then
Set FoundCell = .Find(What:=c.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not FoundCell Is Nothing Then c.Offset(0, 1).Value = FoundCell.Offset(0, 2).Value + c.Offset(0, 1).Value
End If
Next c
End With
Neither does this.
Code:
For Each c In Range("F25:F33").Cells
If Not IsEmpty(c.Value) Then
Set FoundCell = Range("F13:F22").Find(What:=c.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not FoundCell Is Nothing Then c.Offset(0, 1).Value = FoundCell.Offset(0, 2).Value + c.Offset(0, 1).Value
End If
Next c
The result of both are that the values are not updated.
The purpose of the script is the find all values from F25:F33 in F13:F22 and update G25:G33 with value from H13:H22.