excel - 想要在 n 次复制功能中复制单元格值而不是公式
问题描述
Sub CopyHeaders()
Dim copyTimes As Long
Dim i As Long
Dim n As Integer
copyTimes = Range("B3")
If copyTimes > 0 Then
For i = 1 To copyTimes
Range("C3").Copy Cells((i * 1) + 1, "F")
Next i
End If
End Sub
解决方案
这似乎对我有用。
Option Explicit
Sub CopyHeaders()
Dim copyTimes As Long
copyTimes = Range("B3")
If copyTimes > 0 Then
Range("F2").Resize(copyTimes).Value = Range("C3").Value
End If
End Sub
如果您想更好地控制粘贴类型(例如,仅值、仅值和数字格式等),您也可以使用Range.Copy
and 。Range.PasteSpecial
推荐阅读
- ssh - 几天后,Bitbucket ssh 密钥似乎“过期”
- powerbi - 使用 Azure Synapse Analytics 时是否需要配置网关
- php - 我在哪里可以找到 Shopware 6 中的图标列表?
- php - 使用 laravel 从大表中删除重复项
- python - 根据符合特定标准的观察结果创建新的 Pandas 数据框
- node.js - 使用 NodeJS 在其他数据之前解析 CSV 和公共数据
- jdbc - 在 Java 代码中执行查询以连接到 Presto 时出错
- opengl - opengl中的人脸剔除是否发生在窗口空间中?
- c++ - QT C++ 或 VC++ 中的 Onvif 相机流和控制
- multipartform-data - 在 maven 应用程序中使用 resteasy multipart provider jboss 模块