fadee2
Active Member
- Joined
- Nov 7, 2020
- Messages
- 404
- Office Version
- 2021
- Platform
- Windows
hi all,
I am trying to match a value in a range of cells, using vba.
my worksheet looks like this
and this is my code
the motive is to sum values in column if value in b1 or c1 matches the vakue in j1.
the code returns unable to get match property error, please refer to below image.
I am unable to figure out the missing link in the above code.
I can use index to return the value, which is working fine also, but I am trying to figure out what has gone wrong with Match function. any help is appreciated.
I am trying to match a value in a range of cells, using vba.
my worksheet looks like this
Daily_Wages_Computations.xlsm | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | J | ||||||||
1 | Name | 01/12/20 | 01/01/21 | 01/12/20 | ||||||||
2 | A | 30000 | 1000 | |||||||||
3 | B | 21500 | 200 | |||||||||
4 | C | 12000 | 500 | |||||||||
5 | D | 26500 | 1000 | |||||||||
6 | E | 22000 | 6000 | |||||||||
7 | F | 22000 | 5000 | |||||||||
8 | G | 22000 | 6000 | |||||||||
Sheet4 |
and this is my code
VBA Code:
Sub matchVal()
Dim lookmon As Range
Set look_mon = Sheets("sheet4").Range("b1:f1") 'lookup range
lookval = Range("b1") 'lookup value
Sheets("sheet4").Range("f20") = WorksheetFunction.Match(lookval, look_mon, 0)
End Sub
the code returns unable to get match property error, please refer to below image.
I am unable to figure out the missing link in the above code.
I can use index to return the value, which is working fine also, but I am trying to figure out what has gone wrong with Match function. any help is appreciated.