尝试找到最后一个填充的行后,我的宏不会停止运行

问题描述 投票:0回答:1

我想将一个单元格的值粘贴到表第10列的每个单元格中。但是,我只希望它对填充的行这样做。添加这些代码行后,宏将无休止地运行。

Worksheets("Inspections").Activate     

With Worksheets("Inspections")
    rowq = .Range("A" & .Rows.Count).End(xlUp).row
    Range(.Cells(3, 10), .Cells(rowq, 10)).Value = Range("L1").Value
End With
excel vba
1个回答
0
投票

我使用此代码解决了该问题。仍然不确定为什么原图不起作用。

   With Worksheets("Inspections")
         rowq = Cells.Find(What:="*", _
                     After:=Range("A1"), _
                     LookAt:=xlPart, _
                     LookIn:=xlFormulas, _
                     SearchOrder:=xlByRows, _
                     SearchDirection:=xlPrevious, _
                     MatchCase:=False).row
         Range(.Cells(3, 10), .Cells(rowq, 10)).Value = Range("L1").Value
    End With
© www.soinside.com 2019 - 2024. All rights reserved.