Reputation: 329
i have to ask that how can search the value and ! delete the differents
if i have data like this below in column A B C
and in cell A1 from sheet(2) have "bbb"
what function or VBA should i use to get rid of cell in column A and B on row that not contain bbb
try using macro record but it wont work well
A B C
aaa-1.1.1.1 aa1a1a1a1a1 remark
bbb-2.5.2.2 b2b2b2b2b2b2 remark
ccc-3.3.3.3 c3c3c3c3c3c3 remark
bbb-1.2.2.5 b2b2b2b2b2b2 remark
ddd-4.1.2.4 d4d4d4d4d4d4 remark
bbb-1.3.2.7 b2b2b2b2b2b2 remark
bbb-2.2.2.2 b2b2b2b2b2b2 remark
result should be like
A B C
remark
bbb-2.5.2.2 b2b2b2b2b2b2 remark
remark
bbb-1.2.2.5 b2b2b2b2b2b2 remark
remark
bbb-1.3.2.7 b2b2b2b2b2b2 remark
bbb-2.2.2.2 b2b2b2b2b2b2 remark
Thank you for every help i can get :)
Upvotes: 0
Views: 201
Reputation: 5866
If you're not looking for an automated solution (e.g. this is a one-and-done scenario, no programming or recording required), you could simply sort
the data based on Column A
's values, then the deletion process is trivial. In short:
bbb
. This can be done by holding CTRL
while making a selection.Here's some screen shots of these steps and the result
Sort the data
Select rows above and below bbb
Press the Delete
key (Result)
Upvotes: 1
Reputation: 46
Use vba
The following would stop when it gets to an empty line...
x = 1
While Cells(x, 1) <> ""
If Left(Cells(x, 1), 3) <> "bbb" Then
Cells(x, 1) = ""
Cells(x, 2) = ""
End If
x = x + 1
Wend
Upvotes: 1