|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Private Sub Worksheet_Change(ByVal Target As Range)
- Dim rG As Range, i&, j&
- Application.EnableEvents = False
- If Target.Column = 1 And Target.Row >= 3 And Target.Row <= 127 Then
- Dim searchValue As Variant
- searchValue = Target.value
- Dim sheet1 As Worksheet
- Set sheet1 = ThisWorkbook.Sheets("Sheet1")
- searchValue = Target.value
- Target.EntireRow.ClearContents
- If searchValue <> "" Then
- Set rG = sheet1.[a3:a127].Find(searchValue)
- Dim sourceRange As Range
- Set sourceRange = sheet1.Rows(rG.Row)
-
- Dim destinationRange As Range
- Set destinationRange = Target.EntireRow
- If Not rG Is Nothing Then
- For j = 1 To sourceRange.Columns.Count
- value = sourceRange.Cells(1, j).value
- If IsNumeric(value) Then
- If value = 0 Then
- destinationRange.Cells(1, j).value = ""
- Else
- destinationRange.Cells(1, j).value = Val(value)
- End If
- Else
- destinationRange.Cells(1, j).value = value
- End If
- Next j
- End If
- End If
- End If
- Application.EnableEvents = True
- End Sub
复制代码 |
|