![](/img/trans.png)
[英]Excel - VBA code to add a column ID and then combine all sheets into a sheet
[英]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.