The macro counts the number of times criteria from column B is found exactly in a range in column A. The macro loops through all populated rows in column B to perform this countif function. However, the user wants the countif to check if the range contains the criteria, not just an exact match. For example, if the criteria is "Manager" and the range contains "Marketing Manager", it should count it. The code provided shows the current macro that performs the countif with an exact match for each row in column B.
The macro counts the number of times criteria from column B is found exactly in a range in column A. The macro loops through all populated rows in column B to perform this countif function. However, the user wants the countif to check if the range contains the criteria, not just an exact match. For example, if the criteria is "Manager" and the range contains "Marketing Manager", it should count it. The code provided shows the current macro that performs the countif with an exact match for each row in column B.
The macro counts the number of times criteria from column B is found exactly in a range in column A. The macro loops through all populated rows in column B to perform this countif function. However, the user wants the countif to check if the range contains the criteria, not just an exact match. For example, if the criteria is "Manager" and the range contains "Marketing Manager", it should count it. The code provided shows the current macro that performs the countif with an exact match for each row in column B.
I have a macro which does the countif function checking the criteria from the column B in arange in a column A. Both (range and criteria) might have different size, so the macro goes until the last cell populated. However, it checks exactly the same matches. I would like to transform it to check if the range contains the criateria. For instance, if the criteria is "Manager" and in the range we have "Marketing Manager", I would like to count it. Below you can find the screenshot of the excel file and the code of my macro.
Macro Code: Sub Countif_Until_LastRow()
Dim lastRowColumnB As Long lastRowColumnB = Range("B65000").End(xlUp).Row
For i = 2 To lastRowColumnB Cells(i, 3) = Application.CountIf(Range("A:A"), Cells(i, 2)) Next End Sub