excel - 尽管使用不同的方法在vba中剪切和粘贴相同的单元格,但输出不同?
问题描述
下面是我的代码,我想剪切和粘贴一系列单元格。编码
Currentsheet.Range("F26:G26").Cut Destination:=Currentsheet.Range("F25:G25")
设法给了我正确的输出并粘贴了我在每个工作表上选择的单元格范围,从 sheetnumber 2 到最后一个 sheetnumber 但代码
Currentsheet.Range(Cells(26, 6), Cells(26, 6 + 1)).Cut Destination:=Currentsheet.Range(Cells(25, 6), Cells(25, 6 + 1))
只设法将单元格范围剪切并粘贴到我的最后一张纸上。即使两者都选择相同范围的单元格进行剪切和粘贴,为什么会出现这种情况?
For sheetnumber = 2 To ThisWorkbook.Sheets.Count
Set Currentsheet = ThisWorkbook.Sheets(sheetnumber)
For Column = 4 To Currentsheet.Cells(11, Columns.Count).End(xlToLeft).Column
If Currentsheet.Cells(25, Column) > 300 And Currentsheet.Cells(25, Column) < 500 Then
Currentsheet.Rows(25).Insert shift:=xlShiftDown
'Currentsheet.Range(Cells(26, 6), Cells(26, 6 + 1)).Cut Destination:=Currentsheet.Range(Cells(25, 6), Cells(25, 6 + 1))
Currentsheet.Range("F26:G26").Cut Destination:=Currentsheet.Range("F25:G25")
End If
Next Column
Next sheetnumber
解决方案
我不确定理解
Currentsheet.Range(Cells(26, 6), Cells(26, 6 + 1))
Cells(26,6)
这个 Range Express 的意思是“ActiveSheet.cells(26,6)”所以,最好明确地使用它 Like
Currentsheet.Range(Currentsheet.Cells(26, 6), Currentsheet.Cells(26, 6 + 1))
推荐阅读
- json - 如何使用谷歌脚本获取数组中的特定 api 响应路径
- sql - 查找总成本低于平均 SQL
- c# - CRUD - 创建选择下拉列表自动填充另一个输入框 ASP.NET Razor Pages
- visual-studio-code - 当我尝试添加括号对扩展时,我的 settings.json(VS 代码)有问题
- speech-recognition - Azure diarization(扬声器分离)不起作用
- javascript - 动态创建的表单在 django rest 框架 api POST 上总是被禁止 403
- javascript - 有没有一种简单的方法来判断一个元素是否不可点击?
- powerbuilder - 如何激活 Vscroll xplistbar Advance GUI PowerBuilder
- ajax - 无法在 Laravel 资源控制器中获取发布 Ajax 数据
- python - 我想用我自己的替换html代码