我有这个代码。我可以使用循环使用一个代码复制所有工作表吗?
Sub clearLKP_68()
Sheet7.Cells.Clear
End Sub
Sub copyFromRel68ToLKP_68()
Sheets("Rel 6.8").Columns("A:R").copy Sheets("LKP_68").Range("A1")
End Sub
Sub clearLKP_69()
Sheet8.Cells.Clear
End Sub
Sub copyFromRel69ToLKP_69()
Sheets("Rel 6.9").Columns("A:R").copy Sheets("LKP_69").Range("A1")
End Sub
Sub clearLKP_70()
Sheet9.Cells.Clear
End Sub
Sub copyFromRel70ToLKP_70()
Sheets("Rel 7.0").Columns("A:R").copy Sheets("LKP_70").Range("A1")
End Sub
答案 0 :(得分:1)
这对你有用吗?随意询问是否有任何不清楚的事情。
Option Explicit
Sub test()
Dim separator As String
Dim i As Long
separator = Application.DecimalSeparator
Application.DecimalSeparator = "."
For i = 68 To 70
Worksheets("LKP_" & CStr(i)).Cells.Clear
Worksheets("Rel " & Format(i / 10#, "0.0")).Columns("A:R").Copy Destination:=Worksheets("LKP_" & CStr(i)).Range("A1")
Next i
Application.DecimalSeparator = separator
End Sub