作者:里 | 来源:互联网 | 2023-05-19 15:31
Imtryingtoloopthroughalltheworksheetsinmyworkbook.Oneachsheet,Idliketocopyavalu
I'm trying to loop through all the worksheets in my workbook. On each sheet, I'd like to copy a value from one cell, and paste the value on a different cell in that worksheet, and then continue on through the workbook. The code I've written loops through all the worksheets but only performs the copy paste on the sheet its on when the macro is run...
我正在尝试遍历工作簿中的所有工作表。在每张工作表上,我想从一个单元格中复制一个值,并将该值粘贴到该工作表中的另一个单元格上,然后继续浏览工作簿。我编写的代码循环遍历所有工作表,但只在宏运行时在工作表上执行复制粘贴...
Sub CleanUp()
Dim ws as Worksheet
For Each ws in ThisWorkbook.Sheets
Range("BB2").Copy Range("A1")
Next ws
End Sub
In actuality, I want to run a more complicated series of alterations, but I can't even get this to work right.
实际上,我想进行一系列更复杂的改动,但我甚至无法使其正常工作。
2 个解决方案