excel - 转置并粘贴到运行列表
问题描述
我需要从工作表(“SCAN IN”).column(“C2:ZZ”)上的表格中转置和粘贴数据并粘贴到工作表的最后一行(“SCAN IN2”)以创建运行列表。然后清除工作表上的表格(“SCAN IN”)
我已将表单设置为从工作表(“SCAN IN”)转置并清除目标工作表的内容,然后将数据粘贴到列(“C2:D”)中。
Sub Transfer_Transpose_Scans()
Dim WksScanIn As Worksheet
Dim rBinLocs As Range
Dim rBinLoc As Range
Dim iOutputRow As Long
Dim iColOffset As Long
Dim lastrow As Long
ThisWorkbook.Activate
Set WksScanIn = Worksheets("SCAN IN")
On Error GoTo NoBinLocs
Set rBinLocs = WksScanIn.Columns("C").Cells.SpecialCells(xlCellTypeConstants, xlTextValues)
On Error GoTo 0
Worksheets("SCAN IN2").Activate
Range("C2:D" & Rows.Count).ClearContents
iOutputRow = 1
For Each rBinLoc In rBinLocs
iColOffset = 1
While Len(rBinLoc.Offset(0, iColOffset).Value) > 1
iOutputRow = iOutputRow + 1
Cells(iOutputRow, "C").Value = rBinLoc.Value
Cells(iOutputRow, "D").Value = rBinLoc.Offset(0, iColOffset).Value
iColOffset = iColOffset + 1
Wend
Next rBinLoc
Exit Sub
NoBinLocs:
MsgBox "No bin locations found on " & """" & "SCAN IN" & """" & " worksheet Column c", vbInformation, "No Bin Locations Found"
End Sub
我需要从 Sheets("SCAN IN").column(C2:D) 复制、转置、粘贴到 ("SCAN IN2").column(c:d) 上表的最后一行。
我想清除从工作表(“扫描输入”)中转置和复制的数据。
解决方案
Sub Transfer_Transpose_Scans()
Dim WksScanIn As Worksheet
Dim rBinLocs As Range
Dim rBinLoc As Range
Dim iOutputRow As Long
Dim iColOffset As Long
Dim lastrow As Long
ThisWorkbook.Activate
Set WksScanIn = Worksheets("SCAN IN")
On Error GoTo NoBinLocs
Set rBinLocs = WksScanIn.Columns("C").Cells.SpecialCells(xlCellTypeConstants, xlTextValues)
On Error GoTo 0
Worksheets("SCAN IN2").Activate
'Range("C2:D" & Rows.Count).ClearContents
iOutputRow = Cells(Rows.Count, 3).End(xlUp).Row
For Each rBinLoc In rBinLocs
iColOffset = 1
While Len(rBinLoc.Offset(0, iColOffset).Value) > 1
iOutputRow = iOutputRow + 1
Cells(iOutputRow, "C").Value = rBinLoc.Value
Cells(iOutputRow, "D").Value = rBinLoc.Offset(0, iColOffset).Value
iColOffset = iColOffset + 1
Wend
Next rBinLoc
WksScanIn.Range("C2:XFD" & Rows.Count).ClearContents
Exit Sub
推荐阅读
- razor - 使用 ajax() 发布的 asp.net 核心不显眼验证
- laravel - 如何使用 Homestead、Parallels 和 vagrant 设置 Laravel 开发环境
- apache-kafka - kafka 是否在重新平衡时对传输的分区应用压缩
- c# - 通过谷歌翻译的字符串翻译停止工作
- python - 张量归一化期间的意外输出
- wcf - consume external WCF in netcore 2.0
- mysql - 为相互关注的用户建立雄辩的关系
- julia - 为什么用户定义的类型与 Julia 中的内置语言类型一样快速和紧凑?
- database - 弱实体多对多 ERD 到关系
- python - python中if多个条件的简化