簡體   English   中英

將特定范圍的數據從一張紙復制到另一張紙

[英]Copy a specific range of data from one sheet to other

您好我正在嘗試將特定范圍的數據(即一張紙的 A7 到 A10000 和 C7 到 C10000)復制到另一張紙的 A1 和 B1 單元格。 但我無法使用下面的方法做到這一點

Sheets("Appointment").Columns("A7").Copy Destination:=Sheets("Security Appt_Location").Range("A1")
Sheets("Appointment").Columns("C7").Copy Destination:=Sheets("Security Appt_Location").Range("B1")

我可以在上面的句子中定義范圍嗎?

Columns("A7")是無效規范。 列由字母或索引標識,例如Columns("A")Columns(1)

如果你解決了這個問題,代碼應該可以工作,除非有一些其他情況,比如工作表保護等。

您只復制一個單元格,您的代碼將受益於一些修改以減少重復:

  Dim sht
  Set sht = Sheets("Security Appt_Location")

  With Sheets("Appointment")
     .Range("A7:A10000").Copy Destination:=sht.Range("A1")
     .Range("C7:C10000").Copy Destination:=sht.Range("B1")
  End With

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM