Take all the values with a specific text in the next cell?

Uumas

New Member
Joined
Oct 8, 2017
Messages
3
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Original[/TD]
[TD]Type[/TD]
[TD]Result[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]67[/TD]
[TD]a[/TD]
[TD]98[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]98[/TD]
[TD]a[/TD]
[TD]87[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]238[/TD]
[TD]b[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]9[/TD]
[TD]a[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]98[/TD]
[TD]c[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]45[/TD]
[TD]b[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]87[/TD]
[TD]c[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]9[/TD]
[TD]a[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I want to have only values of type c end up in the results column. I know I could simply use an if statement, but that'd leave empty cells where it isn't type c and I don't want that. How should I do this?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Here is a Vba solution:

Code:
Sub Look_For_C()
'Modified  10/5/2018  7:48:35 PM  EDT
Application.ScreenUpdating = False
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Dim x As Long
Dim r As Range
x = 2
    For Each r In Range("B2:B" & Lastrow)
        If r.Value = "c" Then Cells(x, "C").Value = r.Offset(, -1).Value: x = x + 1
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Formula options. Note that I have changed your sample data slightly.

If you don't care what order the results come in, C2 copied down.
If you want to preserve the original order, D2.

Excel Workbook
ABCD
1OriginalTypeResult
267c9867
398a8798
4238b6787
59a
698c
745b
887c
99a
Type c
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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