Question

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
Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top