2011-10-21 11 views
2

私は簡単な質問があります。たとえば、次のように:特定の項目の記述が含まれてい高度なExcelソート

私はExcelシートを持っている...

1) Awesome mirror 
2) Another Awesome mirror 
3) beautiful table 
4) Pretty beautiful lovely sofa 
5) one more mirror 

and so on... 

だから、一緒に、私は一緒にすべてのミラーを配置したい、と言うのすべてのテーブルができます... とそういうわけで、基本的には "ミラー"という言葉を含むすべてのインスタンスを返すことができるものです。

この問題を解決する方法はありますか?

+1

ラインアイテムは一つの "もの" 以上のものを含めることはできますか?例えば;素晴らしいテーブルと鏡の組み合わせ "または"優れたソファテーブル " –

答えて

3

あなたは以下のように調製溶液を使用することができます。

=SUM(COUNTIF(A1,"*"&{"table","mirror","sofa"}&"*")*{1,100,1000}) 

が得られます
sofa簡単にできるように1000年

のスコアのスコアのスコア数値ソート。

それは、細胞がmirrorsofaの両方を含んでいる可能性だった場合、それはあなたがいずれかのかもしれない。この場合には101のスコアを得るでしょうが:

  • は、マルチマッチの別のリストを持って幸せになります
  • マルチマッチをどのように処理するかを指定できる場合は、さらに式を適合させることができます。

enter image description here

0

あなたは、新しい列を作成し、このUDFを使用することができます。

Function WhatIsIt(LineItem As Range, AllThings As Range) As String 
    Dim rv As String, c As Range 
    Dim v As String, thing As String 

    v = UCase(LineItem.Cells(1).Value) 
    rv = "" 

    If Len(v) > 0 Then 
     For Each c In AllThings.Cells 
      thing = c.Value 
      If Len(thing) > 0 And InStr(v, UCase(thing)) > 0 Then 
       rv = thing 
       Exit For 
      End If 
     Next c 
    End If 
    WhatIsIt = rv 
End Function 

「AllThings」あなたが見てみたいもののリストを持つ範囲です。最初に長い言葉を入れてください: "ソファーテーブル"は "ソファ"または "テーブル"の前に来るべきです。

いくつかの改善点があります:用語が項目説明の別の単語の一部にすぎない場合は、一致も返されます。

2

別の可能性としては、ADOです。アイテムが2回出現すると、2行が返されます。また、許可されToFind内の別の列で遊ぶことも可能であろうNot LikeLike '%' & [ToFind] & '%' And Not Like '%' & [NotToFind] & '%'

入力

enter image description here

結果

enter image description here

Dim cn As Object 
Dim rs As Object 
Dim strFile As String 
Dim strCon As String 
Dim strSQL As String 
Dim s As String 
Dim i As Integer, j As Integer 

''This is not the best way to refer to the workbook 
''you want, but it is very convenient for notes 
''It is probably best to use the name of the workbook. 

strFile = ActiveWorkbook.FullName 

''Note that if HDR=No, F1,F2 etc are used for column names, 
''if HDR=Yes, the names in the first row of the range 
''can be used. 
'' 
''This is the Jet 4 connection string, you can get more 
''here : http://www.connectionstrings.com/excel 

strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFile _ 
    & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";" 

''Late binding, so no reference is needed 

Set cn = CreateObject("ADODB.Connection") 
Set rs = CreateObject("ADODB.Recordset") 

cn.Open strCon 

''[ToFind] is a named range, but it does not have to be. 
strSQL = "SELECT DISTINCT [List], [ToFind] " _ 
     & "FROM [Sheet1$A:A] a, " _ 
     & "[ToFind] b " _ 
     & "WHERE List Like '%' & [ToFind] & '%'" 

rs.Open strSQL, cn, 3, 3 


''Pick a suitable empty worksheet for the results 

Worksheets("Sheet2").Cells(2, 1).CopyFromRecordset rs 

''Tidy up 
rs.Close 
Set rs = Nothing 
cn.Close 
Set cn = Nothing 
0

リストにすべての "テーブル"を表示したい場合は、検索フィールドにAutofilterの終了タイプのテーブルを使用してください。この方法では、文字列内の単語 "テーブル"の項目だけが表示されます。他の行はすべて非表示になります。

よろしく、

ロバート