문제

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?

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
도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top