VB

前端之家收集整理的这篇文章主要介绍了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.f2er.com/vb/258670.html

猜你在找的VB相关文章