微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VB

Sub copy_To_Another_Sheet()

Dim FirstAddress As String

Dim Arr As Variant

Dim Rng As Range

Dim Rcount As Long

Dim I As Long


Application.ScreenUpdating = False

Arr = Array("x","y")


Rcount = 0

With Sheets("jd_soy").Range("g1:G3019")


For I = LBound(Arr) To UBound(Arr)



Set Rng = .Find(what:=Arr(I),_

After:=.Rows(.Rows.Count),_

LookIn:=xlFormulas,_

LookAt:=xlPart,_

SearchOrder:=xlByRows,_

SearchDirection:=xlNext,_

MatchCase:=False)

If Not Rng Is nothing Then

FirstAddress = Rng.Address

Do

Rcount = Rcount + 1

Rng.EntireRow.copy


Rng.EntireRow.copy Sheets("test").Range("A" & Rcount).End(xlUp).Offset(1)

'Sheets("test").Range("A" & Rcount).Value = Rng.Cells



' Worksheets("test").Cells(Rng,1).Value = Rng.Row

Set Rng = .FindNext(Rng)

Loop While Not Rng Is nothing And Rng.Address <> FirstAddress

End If

Next I

End With

Sheets("test").Select

Cells.Select

Cells.EntireColumn.AutoFit

Range("A1").Select

End Sub

原文地址:https://www.jb51.cc/vb/258670.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐