0

マクロを使用して簡単なツールを作成したいのですが、一致する場合はD列の「R」テキストを検索し、そのセル値をコピーして「L」列に貼り付けます。

以下のスクリプトのマクロを実行すると、正確な値を取得できますが、これは1つのセルであるため、D列全体を見つけるのに誰かが助けてくれます。

D                  L

1111_r             1111_r
0000
22222
348_16re
111
222
333_16re
Dim c As Range
    With ActiveWorkbook.Sheets("PLMSync_NetChange")
        Set c = .Range("D1:D20").Find(What:="_R", _
                                   LookIn:=xlFormulas, LookAt:=xlPart, _
                                   SearchOrder:=xlByRows, _
                                   SearchDirection:=xlNext, MatchCase:=True)
        On Error GoTo NotFoundErr:
            c.Offset(0, 15).Value = c.Value
    End With
    Exit Sub
NotFoundErr:
    Debug.Print "value not found"
End Sub

どうもありがとうございました。現在は機能しています......このプロセスの後、L列の値を制限内のAcloumnと比較する必要があります。L列から_valusの前に取得し、アイテムiDセルの下からbom更新セルの上まで(制限付きで)A列を検索します。一致する場合は、コピーしてM列に貼り付けます。

ここにはっきりと示されている例を添付しました。

   A       B       C       D    L           M
BOM Update report for car               
Summary: Additions=14;Removals=10;Changes=3;Same=20             
Add         Remove  Remove
Item Id Revision    ProFeatureID    Item Id 
xxxxxx  0   795 3S2093_L    
xxxxxx  0   802 3S2093_L    
xxxxxx  0   790 3S2093_L    
yyyyyy  0   720 3S2093_L    
yyyyyy  0   817 3S2093_L    
yyyyyy  0   740 3S2093_L    
zzzzzz  0   732 11111_re    11111_re   11111
zzzzzz  0   746 11111_re    11111_re   11111
zzzzzz  0   758 11111_re    11111_re   11111
zzzzzz  0   766 11111_re    11111_re   11111
11111   2   774     
11111   2   777     
11111   2   780     
11111   2   783     
BOM Update report for bike  
4

3 に答える 3

0
Dim LvRow As Integer

Dim LvCol As Integer

lastrow = Range("D65354").End(xlUp).Row

LvCol = 4

For LvRow = 1 To lastrow

  If InStr(1, Cells(LvRow, LvCol), "R",vbtextcompare) > 0 Then

      Cells(LvRow, LvCol).Select

      Cells(LvRow, LvCol + 8).Value = Cells(LvRow, LvCol)


 End If

Next
于 2013-03-01T05:21:52.897 に答える
0
Sub sample()

    Dim lastRow As Long
    Dim rng As Range

    With Sheets("PLMSync_NetChange")
        .Activate
        lastRow = .Range("D65000").End(xlUp).Row

        For i = 1 To lastRow
            If (InStr(1, .Range("D" & i).Value, "r", vbTextCompare) > 0) Then
                .Range("L" & i).Value = .Range("D" & i).Value
            End If

        Next

    End With

    Exit Sub

NotFoundErr:
    Debug.Print "value not found"
End Sub
于 2013-03-01T05:24:07.517 に答える
0

Dim lvrow As Integer

lastrow = Range("A65354").End(xlUp).Row

lvrow = 1 の場合 lastrow へ

If (InStr(1, Cells(lvrow, 12), "1") > 0) その後

If CStr(Mid(Cells(lvrow, 12), 1, InStr(1, Cells(lvrow, 12), "_") - 1) )=CStr(Cells(lvrow, 1)) Then
    Cells(lvrow, 13) = Cells(lvrow, 1)
    Cells(lvrow, 14) = "Match Found"
End If

終了条件

他の列の値を col M に貼り付けたい場合は、列番号を変更してください。

于 2013-03-01T06:53:14.670 に答える