0
セルに含まれる値に基づいてセルを見つける方法は豊富ですが、セルに1つの値しか含まれていない場合の例です。私はdeDE、esesのようなロケールのリストを持つこの列を持っています。もしそれらのロケールのうちの1つだけに基づいてセルを見つけようとすると、私のコードは動作しません。例えばセルを見つけるためのVBAコードには(.csvリストの中で)特定の文字列が含まれています
Sub Test()
Dim strConcatList As String
Dim cell As Range
strConcatList = "*" & "esES" & "*"
'For each used cell in Column A of sheet1, check whether the value in that cell
'is contained within the concatenated string
For Each cell In Intersect(Sheets("Requests").Range("G:G"), Sheets("Requests").UsedRange)
If InStr(strConcatList, cell.Value) > 0 Then 'InStr returns 0 if the string isn't found
matchRow = cell.Row
Rows(matchRow & ":" & matchRow).Select
Selection.Copy
Sheets.Add.Name = "esES"
Sheets("Sheet2").Select
ActiveSheet.Rows(matchRow).Select
ActiveSheet.Paste
Sheets("Requests").Select
End If
Next cell
End Sub
、このコードスニペットは、「のESE」が存在する場合、細胞を見つけるのESEと呼ばれる新しいシートを作成し、その中の行を貼り付けることになっています。私は "esES"を試して、うまくいきませんでした。私は現在のフォームがうまくいくことを願っていました - 私はVBAではないにもかかわらず、Regaxの経験は少しありますし、何か+ eses +何かを読むべきです。
何が起こっているのか分からず、私は何時間も立ち往生しています。私はここで少し助けても構いません。
Sub Test()
Dim strConcatList As String
Dim cell As Range
Sheets.Add.Name = "esES"
strConcatList = "*esES*"
'For each used cell in Column G of sheet1, check whether the value in that cell
'is contained within the concatenated string
For Each cell In Intersect(Sheets("Requests").Range("G:G"), Sheets("Requests").UsedRange)
If cell.Value Like strConcatList Then
matchRow = cell.Row
Rows(matchRow & ":" & matchRow).Select
Selection.Copy
Sheets("esES").Select
ActiveSheet.Rows(matchRow).Select
ActiveSheet.Paste
Sheets("Requests").Select
End If
Next cell
End Sub
ワイルドカードinstr( "Nath"、文字列)または '* Nath *'のような文字列(スペースなし、イタリック体になっています) –
コード内のコメント列* * A **ですが、コードは** G **列のみを調べます。 –
もし 'If InStr(strConcatList、cell.Value)> 0ならば' 'with'もしcell.ValueがstrConcatListなら ' –