带文本variables的macros改变列

macros很好,直到文字的位置改变列。 我使用“查找”文本string,然后想要将光标向右和向下移动2,然后将数据复制到另一个工作表。 该macros很好地工作,直到文本string在后续的电子表格中移动。

如何根据find的文本string将选定范围变为可变的?
在下面的例子中,我如何获得Range("H7:H180").Selectvariables?

 Range("A1").Select Cells.Find(What:="reg", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate Range("H7:H180").Select 

 Dim wks As Worksheet Dim rngFound as Range Set wks = Sheets("Sheet1") ' adjust for your sheet name Set rngFound = wks.Cells.Find(What:="reg", After:=Range("A1"), LookIn:=xlFormulas, LookAt:= _ xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False) If Not rngFound is Nothing Then rngFound.Offset(2,1).Copy Sheets("Sheet2").Range("A1") 'adjust the destination to fit what you need 

不需要select任何东西。 你可以直接使用单元格。 另外,不确定要复制到其他工作表中的哪个位置,但是可以根据需要调整复制目的地。