我使用下面的代码将行从Sheet1复制到SHEET2。我有三个问题。
Sub COPY_SA()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim rng As Range, rngToCopy As Range
Dim lastrow As Long
'change Sheets to suit
Set ws1 = ThisWorkbook.Worksheets("SA")
Set ws2 = ThisWorkbook.Worksheets("JC_input")
With ws1
'assumung that your data stored in column A:D, Sheet1
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rng = .Range("A2:D" & lastrow)
'clear all filters
.AutoFilterMode = False
With rng
'apply filter
.AutoFilter Field:=4, Criteria1:=">0"
On Error Resume Next
'get only visible rows
Set rngToCopy = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
'copy range
If Not rngToCopy Is Nothing Then rngToCopy.CopyDestination:=ws2.Range("A2")
'clear all filters
.AutoFilterMode = False
End With
Application.CutCopyMode = False End Sub
我设法修改如下。工作表“WS1”中的范围仍然存在问题。无法在第二行设置筛选器并从第3行复制范围。这就是为什么添加:“ws2.rows(3).delete”。代码始终复制第1行。第1行得到了一些评论。第2行得到列名。
Sub COPY_SA()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim rng As Range, rngToCopy As Range
Dim lastrow As Long
'change Sheets to suit
Set ws1 = ThisWorkbook.Worksheets("SA")
Set ws2 = ThisWorkbook.Worksheets("JC_input")
With ws1
'assumung that data stored in column C:E, Sheet1
lastrow = .Cells(.Rows.Count, "C").End(xlUp).Row
'can not make range from row 3 ???
Set rng = .Range("C1:E" & lastrow)
'clear all filters
.AutoFilterMode = False
With rng
'apply filter with criteria in column 3 of range C:E
'can not make filter in row 2 ???
.AutoFilter Field:=3, Criteria1:=">0"
On Error Resume Next
'get only visible rows
Set rngToCopy = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
'copy range
If Not rngToCopy Is Nothing Then rngToCopy.Range("A:C").Copy
'paste from row 3
ws2.Range("A3").PasteSpecial Paste:=xlValues
'delete no needed row
ws2.Rows(3).Delete
'clear all filters
.AutoFilterMode = False
End With
Application.CutCopyMode = False
If Not ActiveSheet.AutoFilterMode Then
ws1.Range("2:2").AutoFilter
End If
End Sub
假设两个工作表的标题都在第一行,请尝试此快速修复方法:
Sub COPY_SA()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim rng As Range, rngToCopy As Range
Dim lastrow As Long
'change Sheets to suit
Set ws1 = ThisWorkbook.Worksheets("SA")
Set ws2 = ThisWorkbook.Worksheets("JC_input")
With ws1
'assumung that your data stored in column A:D, Sheet1
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set rng = .Range("A1:D" & lastrow)
'clear all filters
.AutoFilterMode = False
With rng
'apply filter
.AutoFilter Field:=4, Criteria1:=">0"
On Error Resume Next
'get only visible rows
Set rngToCopy = .SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
'copy range
If Not rngToCopy Is Nothing Then rngToCopy.Range("A:A,C:D").Copy
ws2.Range("A1").PasteSpecial Paste:=xlValues
'clear all filters
.AutoFilterMode = False
End With
Application.CutCopyMode = False
End Sub
来回答你的问题:
我想要实现的目标: 当最后一列指示TRUE时,我将向相应的收件人发送一封电子邮件(创建一个按钮并将其分配给脚本) 仅当最后一列指示TRUE时将数据从Sheet1移动/复制到Sheet2 移动到Sheet2的数据将写入新行(追加新行) Sheet1中的数据将被删除,但不会影响Sheet2中的数据。 问题是什么: 数据不会从表1移动到表2 以下是我的代码:
我需要创建一个按钮,当我点击它时,我复制一个我正在使用的特定链接。js 这是我的按钮 当我点击这个按钮时,我需要剪贴板上有类似“https::/google.com”的内容
如何将div中的文本复制到剪贴板?我有一个div,需要添加一个链接,将文本添加到剪贴板。有解决办法吗? 单击“复制文本”后,然后按CtrlV,必须粘贴该文本。
我正在写我的第一个脚本之一,并试图研究其他类似的问题。 我有两张表:Sheet1:新数据(只有C列感兴趣,其他列中的所有内容都可以忽略)Sheet2:旧数据(但如果尚未存在,则需要使用Sheet1新数据更新)。要添加的数据应该在存量数据之后的C列末尾。 我拥有的代码有以下编译错误。我需要-获取C列Sheet2的最后一行。然后检查列C表1是否存在于列C表2中,如果不存在-从表1复制到表2列C。 更新
大家好,我想要复制按钮在我的移动网站,我已经实现了它与JS,它工作良好的android但在ios文本不复制,有没有办法复制文本在ios safari? 这是我在android浏览器上工作的代码 谢谢
我在pygame中为点击事件制作了按钮,但存在一个问题。当我单击鼠标按钮并在按钮边界之间移动鼠标时,单击事件会重复自身。我只想单击一下,直到松开鼠标按钮。我该怎么做?