|
请高手帮帮我
就是我要把一个工作簿的内容复制到另一个工作簿,并且把第一列中的内容中后面两个字带“合计”和“小计”的单元格删除掉,代码如下
Sub CopyRow()
Dim i As Integer
Dim s As String
Dim c As String
Worksheets("Sheet1").Select
With Selection.CurrentRegion
i = .Rows.Count
'i = Worksheets("Sheet1").UsedRange.Rows.Count
For n = 1 To i
s = CurrentRegion.Cells(0, n).Value
c = VBA.Right(s, 2)
If c = 小计 Or 合计 Then
Worksheets("Sheet1").Rows(n).Delete
End If
Worksheets("Sheet1").Rows(n).copy
Worksheets("Sheet2").Select
Worksheets("Sheet2").Rows(n).Select
Worksheets("Sheet2").Paste
Next n
End With
End Sub
我运行时老是提示 s = CurrentRegion.Cells(0, n).Value这行出错,大家告诉我取单元格的值,是怎么写的
|
|