excel - 循环复制具有特定数据的整行并粘贴到下一行
问题描述
我想要做什么:用户输入一个日期(例如 2021-11-05),对于在 Col A 中与此日期匹配的所有单元格,复制整行并粘贴到下一行。
问题:将第 3 行复制到第 4 行时,第 4 行的日期变为 2021-11-05,然后将第 4 行复制到第 5 行,然后再复制到第 6 行,然后继续。
Sub Macro1()
Dim Myinput As Date
Myinput = InputBox("What is the date you want to copy from?")
Dim cell As Range
Dim rw As Long
For Each cell In Range("A1:A15").Cells
If cell.Value = Myinput Then
rw = cell.Row + 1
cell.EntireRow.Copy
Range("A" & rw).Activate
ActiveSheet.Paste
End If
Next
End Sub
解决方案
推荐阅读
- python - 在列表元素的选定部分中查找子字符串
- perl - 我可以在我的 Perl 包中压缩我的导出例程吗?
- java - java Serializable接口没有功能,为什么会影响“writeObject”/“readObject”
- java - 在 Eclipse 中,Junit 不会从 src/test/resources 文件夹中获取文件。
- android - Recyclerview 支持库在带有 android jetpack 的 buildtoolversion 28.0.3 中不起作用
- javascript - 检测保存页面到磁盘
- python - 使用 automap_base 和 alembic 迁移/复制数据库
- html - 在 Safari 中初始加载后 MP4 不播放
- c# - 如何将 UTC 转换为澳大利亚东部夏令时间 (AEDT)?
- php - 使用php构建html表