2017-05-12 10 views

答えて

0

私はこれを解決するVBスクリプト作成しました:

Sub DetermineFeatures() 
Dim featureLabel As String 


Dim testString As String 
testString = "FEAT_EMV_L4, Team_1, Team_IBM" 

Dim stringValue As Variant 

Dim lookupRange As Range 
Set lookupRange = Worksheets("LookupTable").Range("A1:B100") 
Dim outputWorksheet As Worksheet 
Set outputWorksheet = Worksheets("Output") 


Dim feature As String 

Dim rowIndex As Long 

For Each cell In Worksheets("Original").Columns("O").Cells 
    rowIndex = cell.Row 
    cellValue = WorksheetFunction.Trim(cell.Value) 

    For Each stringValue In Split(cellValue, ",") 
     If InStr(stringValue, "LABEL_") Then 
      featureLabel = Trim(stringValue) 

      ' Call the Vlookup function to look up the actual feature name 
for the supplied label. This 
      ' returns the value from the second column of the range within 
the LookupTable worksheet. 
      feature = Application.WorksheetFunction.VLookup(featureLabel, 
lookupRange, 2, False) 

      outputWorksheet.Cells(rowIndex, 1) = feature 


      If Not IsEmpty(featureLabel) Then Exit For 
     End If 
    Next 
Next cell 
End Sub 
0

あなたはそれでうまくある場合は、私が配置に変更を示唆しています。

enter image description here

columns F, G and Hでは、画像のようにルックアップ値を配置し、次の対応する行の値を置き換えます。 3つの参照欄が必要です(3つの参照値があるため)。 Column B, C and Dはヘルパー列です。 Fはあなたのである

ただ、範囲全体下にドラッグして、右の点で最大の列にドラッグ

column BB1を下記の式を入力しますE.

コラム実際の出力。列F、

=B1&C1&D1

て、それを下にドラッグして数式を入力します。お役に立てれば。あなたが何か他のものが必要な場合は教えてください。

+0

こんにちは@のgowtham-シヴァを、私はあなたの式は、仕事を得るように見えることはできません。 Excelはそれが有効ではないと言います。しかしこれは素晴らしい解決策のようです。数式をもう一度見てもらえますか? – Antenne

+0

@Antenneそれは私のためにうまく動作します。カンマをセミコロンに変更して、数式で1回試すことはできますか –

0

これは機能しますが、それほどエレガントではなく、容易に拡大/縮小できません。

=CONCATENATE(REPT($E$1,COUNTIF(A1,"*"&$D$1&"*")),REPT($E$2,COUNTIF(A1,"*"&$D$2&"*")),REPT($E$3,COUNTIF(A1,"*"&$D$3&"*"))) Example Excel Formula

それはREPT(Replacement,COUNTIF(Values,*Labels*))のシリーズです。検索の前後にある*はワイルドカードにすることができます。要素が含まれているかどうかをCOUNTIFのフラグに設定します。次に、置換値をcountifが存在する回数(この例では常に1です)と繰り返して、結果を連結します。

関連する問題