J
Jacek Zagaja
Combobox1 stores unique list of items from data sheet. User clicks on
command button and VB macro prints selected item to the cell. Now with
SUM.PRODUCT I'd like to find selected item in "Item" column and sum
all its values marked KK stored in another column (offset):
=SUM.PRODUCT((Item="selected item")*(Value))
It works nicely but I need to subtract values marked MM that is a
substring of e.g.. 00/11/22/MM/333 II so I added third conditional
(multiplication) that search in KKMM column for MM substring:
TextSearch("MM";KKMM)=True()
It doesn't work so that I'm getting an empty cell. Any ideas?
--
Function TextSearch(ByVal strSearchFor, ByVal Target As Variant) As
Boolean
Dim OneCell As Range
TextSearch = False
If TypeName(Target) = "Range" Then
For Each OneCell In Target
If InStr(1, OneCell.Text, strSearchFor, vbTextCompare) > 0 Then
TextSearch = True
Exit For
End If
Next OneCell
ElseIf TypeName(Target) = "String" Then
If InStr(1, Target, strSearchFor, vbTextCompare) > 0 Then
TextSearch = True
End If
End Function
command button and VB macro prints selected item to the cell. Now with
SUM.PRODUCT I'd like to find selected item in "Item" column and sum
all its values marked KK stored in another column (offset):
=SUM.PRODUCT((Item="selected item")*(Value))
It works nicely but I need to subtract values marked MM that is a
substring of e.g.. 00/11/22/MM/333 II so I added third conditional
(multiplication) that search in KKMM column for MM substring:
TextSearch("MM";KKMM)=True()
It doesn't work so that I'm getting an empty cell. Any ideas?
--
Function TextSearch(ByVal strSearchFor, ByVal Target As Variant) As
Boolean
Dim OneCell As Range
TextSearch = False
If TypeName(Target) = "Range" Then
For Each OneCell In Target
If InStr(1, OneCell.Text, strSearchFor, vbTextCompare) > 0 Then
TextSearch = True
Exit For
End If
Next OneCell
ElseIf TypeName(Target) = "String" Then
If InStr(1, Target, strSearchFor, vbTextCompare) > 0 Then
TextSearch = True
End If
End Function