The below code copies a range from the “Staffing Plan” sheet to the “Resource HourCost” sheet.
It performs correctly when the “Staffing Plan” sheet is active but not when the “Resource HoursCost” sheet is active.
I have tried ActiveWorkbook as well as ThisWorkbook with the same result.
What changes are necessary to run the macro from the “Resource HourCost” or any sheet in the workbook?
As always thanks for your help.
Ron
It performs correctly when the “Staffing Plan” sheet is active but not when the “Resource HoursCost” sheet is active.
I have tried ActiveWorkbook as well as ThisWorkbook with the same result.
What changes are necessary to run the macro from the “Resource HourCost” or any sheet in the workbook?
As always thanks for your help.
Ron
Code:
Sub Staffing()
Dim wb As Workbook
Dim rCount As Long
Dim LastColumn As Integer
Dim wsd As Worksheet
Dim wss As Worksheet
On Error Resume Next
Set wb = ThisWorkbook
Set wsd = wb.Sheets("Resource HoursCost")
Set wss = wb.Sheets("Staffing Plan")
rCount = 34
LastColumn = wss.UsedRange.Columns.Count
wss.Range(Cells(4, 8), Cells(rCount, LastColumn)).Copy Destination:=wsd.Range("L4")
End Sub