我已经通过VBA运行窗口对宏进行了多次测试,并且Sheet2上的所有内容均正确显示。当我尝试从Sheet1上的Button运行宏时,两列“ C”和“ D”将所有数字提高一个单元格。 Button,Sheet1可能是什么问题?
与此同时,此脚本代码已安排为从空行中删除带有其他单词或字母的内容,然后假设要向上删除一行,也许这就是问题所在。
我的代码:
Sub CopyPasteintoSheet2()
Dim lr As Long
Dim i As Long
Dim inputdtae As Date
Dim rng As Range
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr - 0 To 2 Step -1
If Cells(i, "B") = "LLC" Then
Cells(i, "B").EntireRow.Delete
End If
Next i
ActiveWindow.SmallScroll Down:=11
Columns("J:J").Select
Selection.TextToColumns Destination:=Range("J1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Columns("R:R").Select
Selection.TextToColumns Destination:=Range("R1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 1), TrailingMinusNumbers:=True
Dim LastRow As Long
Dim NEWFORMAT As Worksheet
Dim Results As Worksheet
Set Results = Sheets("NEWFORMAT")
LastRow = Results.Cells(Results.Rows.Count, "Z").End(xlUp).Row
Range("A15:A400").Copy
Results.Range("A" & LastRow + 2).PasteSpecial xlValues
Range("B15:B400").Copy
Results.Range("B" & LastRow + 2).PasteSpecial xlValues
Range("J15:J400").Copy
Results.Range("C" & LastRow + 2).PasteSpecial xlValues
Range("R15:R400").Copy
Results.Range("D" & LastRow + 2).PasteSpecial xlValues
Application.DataEntryMode = False
End Sub