我正在尝试使用find函数来查找数据行,并且我想将从A列到H行的所有数据块复制到另一个工作表。但是,find功能不起作用。我是否可以知道我是否正确完成了这一点,而且我非常不确定如何将数据复制到行中。感谢您的帮助。
Dim r, ran, ranOff As Range
Set ran = Cells.Find(What:="# pin/pkgpin Schem Label Pkg Pad
Bank Pkg Label Pad/Bump Coord Probe Coord Pkg Coord")
Set ranOff = ran.Offset(1, 0)
ranOff.CurrentRegion.Select
答案 0 :(得分:1)
尝试下面的代码(代码注释中的解释):
Option Explicit
Sub Importar_Dados()
Dim Ran As Range, RanOff As Range
Dim StrtoFind As String
' modify the string to Find here
StrtoFind = "# pin/pkgpin Schem Label Pkg Pad Bank Pkg Label Pad/Bump Coord Probe Coord Pkg Coord"
Set Ran = Cells.Find(What:=StrtoFind, LookIn:=xlValues, LookAt:=xlWhole)
If Not Ran Is Nothing Then ' <-- Find was able to find a match
Set RanOff = Range("A" & Ran.Row + 1 & ":H" & Ran.Row + 1) '<-- set the range 1 row below, from column A to column H
RanOff.Copy '<-- copy the range
' rest of your code ...
Else ' unseuccessful Find
MsgBox "unable to find " & StrtoFind
End If
End Sub