display results from multiple criteria

kayza

Board Regular
Joined
Apr 29, 2015
Messages
61
Office Version
  1. 2007
Platform
  1. Windows
Hi excel master.
I need help to solve the case of searching and displaying data based on multi criteria using VBA, from the following example:
AB
1100S
2100S
3100J
4103S
5103J
6103S
7104J
8104J
9104S
10......

<tbody>
</tbody>




and here are the results I want to show in column F,G based on critera "S" in column B:
FG
1002
1032
1041
......

<tbody>
</tbody>


thank you in advance, for your help
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
What is the logic in determining the values in F and G?
 
Upvote 0
Hi reberryjr
sorry in advance, i am wrong in giving samples of data and this correct sample data
AB
1intcd
2100S
3100S
4100J
5103S
6103J
7103S
8104J
9104J
10104S
11...

<tbody>
</tbody>


the values in column F are based on the same data contained in column A, while the results in column G are based on the criterion value "S"


Here Is my crude vba code, which can only display the values in column F, but if combined with the "S" criteria (based on column B) the result does not match what I expect
Code:
For n = 2 To 9
a = Cells(n, 1)
ur = Cells(Rows.Count, 6).End(xlUp).Row

[I][COLOR=#000000]'If Cells(n - 1, 1) = a And cells(n-1,2)="S" then '--?[/COLOR][/I]
If Cells(n - 1, 1) = a Then
    Cells(ur, 6) = Cells(n, 1)
    Cells(ur, 7) = Cells(ur, 7) + 1
    Else
    Cells(ur + 1, 6) = Cells(n, 1)
    Cells(ur + 1, 7) = Cells(ur + 1, 7) + 1
End If
Next
 
Last edited:
Upvote 0
So, for row 6 and 7, I assume that you expect to see 103 in column F. What are you expecting to see in column G?
 
Upvote 0
the result in column G is the sum of the criteria for value 100, 103, and 104 (column A) and the "S" criterion (column B).

F G
100 2
103 2
104 1
 
Upvote 0
If you're trying to Sum A and B, then the value in B (J or S) has to have a value. Does J = 1 and S = 2?
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top