excel - Excel VBA单列仅可见单元格到多列(网格)
问题描述
你们能否帮助我并建议代码编辑以使代码在过滤列时也适用于可见单元格。目标数据应转换为连续的多列到列视图。下面的代码按预期工作,除了只能使用过滤的内容,如果列被过滤,则目标视图有空白单元格。很乐意实现没有空白的视图。
Private Sub CommandButton1_Click()
Dim xLRow As Long
Dim xNRow As Long
Dim i As Long
Dim xUpdate As Boolean
Dim xRg As Range
Dim xOutRg As Range
On Error Resume Next
Set xRg = ThisWorkbook.Sheets("Sheet3").Range("A2:A25")
If xRg Is Nothing Then Exit Sub
Set xOutRg = ThisWorkbook.Sheets("Sheet3").Range("A30")
xUpdate = Application.ScreenUpdating
Application.ScreenUpdating = False
xLRow = xRg.Rows.Count
For i = 1 To xLRow Step 5
xRg.Cells(i).Resize(5).Copy
xOutRg.Offset(0, xNRow).PasteSpecial Paste:=xlPasteValues, Transpose:=False
xNRow = xNRow + 1
Next
Application.ScreenUpdating = xUpdate End Sub
提前致谢。
解决方案
推荐阅读
- jquery - 将此纯 javascript 转换为 jquery
- azure - Kubernetes AKS 持久卷磁盘声明到多个节点
- .net - 如何将双引号中的字符串与转义匹配?
- javascript - 绘图带不限于 xAxis,绘制整个图形
- python-3.x - 不同大小的网格 Python 3.00
- python - 使用 pip3 安装 scikit-learn
- reactjs - 未捕获的 TypeError: dispatch(...).then 不是函数
- c++ - 需要从字符串数组的一部分访问元素
- php - 为什么用facebook登录不起作用?(除了检查网址之外,如何调试这个问题?)
- scala - 将 Scala 火花代码移植到 PySpark 时遇到问题