簡體   English   中英

VBA 查找特定單詞並將值復制到另一個單元格

[英]VBA to find specific word and copy value to another cell

我正在尋找有關 vba 的幫助。

我想在 A 列中搜索“CAMBUSLANG 摘要”,如果找到,將 D 列中的值分配給另一個單元格,以便於交談,說另一個電子表格的 A 列。

任何幫助將不勝感激。

使用Range.Find 方法在 A 列中查找您的特定字符串,使用Range.Offset 屬性移動到 D 列:

Option Explicit

Public Sub Example()
    Dim FoundAt As Range
    Set FoundAt = Worksheets("SearchSheet").Columns("A").Find(What:="Summary of CAMBUSLANG", LookIn:=xlValues, LookAt:=xlWhole)

    If Not FoundAt Is Nothing Then 
        Worksheets("AnotherSheet").Range("A1").Value = FoundAt.Offset(ColumnOffset:=3).Value
    Else 'nothing found
        MsgBox "'Summary of CAMBUSLANG' not found.", vbCritical
    End If
End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM