簡體   English   中英

如何編寫代碼VBA以在一張Excel中復制所有圖紙

[英]How to write code VBA for copying all sheets in one sheet excel

工作表1名稱金額abc 25.00 bba 45.00

Sub sbCopyRangeToAnotherSheet()
    Sheets("sheet1").Range("A:B").Copy Destination:=Sheets("Sheet4").Range("a1")
End Sub

如果我有多個工作表,我應該如何而不是將(sheet1)寫入目標文件到工作表4?

Sub sbCopyRangeToAnotherSheet()
   dim col as integer
   col = 1
   For Each wks In Worksheets
      if (wks.Name <> "Sheet4") then
          wks.Range("A:B").Copy Destination:=Sheets("Sheet4").Cells(1, col)
          col = col + 2
      end if
   next wks
End Sub

暫無
暫無

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

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