My below code is not running? Can't seem to figure out why...
我的下面代码没有运行?似乎无法弄清楚为什么......
I'm attempting to copy a named range 22 columns to the left of it using the following code, can someone steer me in the right direction?
我正在尝试使用以下代码将命名范围22列复制到其左侧,有人可以引导我朝正确的方向前进吗?
Thanks!
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
1 个解决方案
#1
0
here are some changes I would suggest:
以下是我建议的一些变化:
Set ws0 = wb.ActiveSheet
and
Select Case ws0.Range("G3").name
and also instead of using the copy command why not just assign values directly, for example:
而且不使用复制命令,为什么不直接分配值,例如:
ws1.range(ws1.cells(1, 20), ws1.cells(10, 2)).value= ws0.range(ws0.cells(1, 1), ws0.cells(10, 1)).value
#1
0
here are some changes I would suggest:
以下是我建议的一些变化:
Set ws0 = wb.ActiveSheet
and
Select Case ws0.Range("G3").name
and also instead of using the copy command why not just assign values directly, for example:
而且不使用复制命令,为什么不直接分配值,例如:
ws1.range(ws1.cells(1, 20), ws1.cells(10, 2)).value= ws0.range(ws0.cells(1, 1), ws0.cells(10, 1)).value