也許最簡單的方法就是隻要找到22 & 23和地方建立的行位於
然後你就可以創建範圍與已知的行和列進行復制。 爲此示例命名工作表「複製到工作表」。
Sub Button1_Click()
Dim Rws As Long, Rng As Range
Dim c1 As String, c2 As String
Dim FndC1 As Range, FndC2 As Range
Dim c1C As Integer, c2C As Integer
Dim ws As Worksheet
Set ws = Sheets("Copy to Sheet")
c1 = 22
c2 = 23
Rws = Cells(Rows.Count, "K").End(xlUp).Row
Set Rng = Range(Cells(1, "K"), Cells(Rws, "K"))
Set FndC1 = Rng.Find(what:=c1, lookat:=xlWhole)
Set FndC2 = Rng.Find(what:=c2, lookat:=xlWhole)
If Not FndC1 Is Nothing Then
c1C = FndC1.Row
Else: MsgBox c1 & " Not Found"
Exit Sub
End If
If Not FndC2 Is Nothing Then
c2C = FndC2.Row
Else: MsgBox c2 & " Not Found"
Exit Sub
End If
Range(Cells(c1C + 1, "C"), Cells(c2C - 1, "J")).Copy _
ws.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End Sub
這是驚人的 - 完美的作品!非常感謝你,你用這段代碼爲我節省了無限的時間。 – 2015-03-03 14:22:49