我的下面的代码没有运行?似乎无法弄清楚为什么......
我正在尝试使用以下代码将命名范围22列复制到其左侧,有人可以引导我朝正确的方向发展吗?
谢谢!
Sub ApplyFutureYears()
Dim wb As Workbook
Dim ws0 As Worksheet
Dim ws1 As Worksheet
Dim destRng1 As String
Dim sorceRng1 As String
Set wb = ThisWorkbook
Set ws0 = wb.Sheets("Selection")
Set ws1 = wb.Sheets("Non-Union Empl HC")
Select Case ws0.Range("G3")
Case "2015LRP"
sorceRng1 = "Copy1": destRng1 = Range("Copy1").Offset(0, -22)
Case Else
Exit Sub
End Select
ws1.Range(sorceRng1).Copy
ws1.Range(destRng1).PasteSpecial Paste:=xlPasteValues, SkipBlanks:=True
End Sub
答案 0 :(得分:0)
以下是我建议的一些变化:
Set ws0 = wb.ActiveSheet
和
Select Case ws0.Range("G3").name
并且不使用复制命令而不是直接分配值,例如:
ws1.range(ws1.cells(1, 20), ws1.cells(10, 2)).value= ws0.range(ws0.cells(1, 1), ws0.cells(10, 1)).value