sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,404
- Office Version
- 2016
- Platform
- Windows
I'm trying to find a way using VBA to sum the total values, (which are numbers), in a range but only if the adjacent cell matches a specific criteria.
I have this but it only gives me the first value found, not the total;
Can anyone show me where I am going wrong please?
I have this but it only gives me the first value found, not the total;
Code:
For Each Cell In SourceFile.Sheets("Data").Range("A7:A30")If Cell <> 0 Then
If InStr(Cell, "Constant") > 0 Then
Total = Cell.Offset(0, 1).Value
MsgBox Total
End If
End If
Next
Can anyone show me where I am going wrong please?