Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
hi all, good morning, hoping you can help , i have the code below where i am triung to copy cell C1 from Sheet1' (another workbook) and paste into 'ROTA' which is another workbook into cells B2 to B27, but its coming up with an errror, can you help me please
Code:
rivate Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim lookuprng As Range
Set wb1 = ThisWorkbook
Set wb2 = Workbooks.Copy("G:\TEAM\ES_Mtr_Tech_Ops\Customer Management Centre\Utilisation\Complex\Rota\Rolling Rota 2017.xlsx")
Set lookuprng = wb2.Sheets("Sheet1").Range("C1")
Set ws1 = wb1.Sheets("ROTA")
ws1.Range("B2:B27").Paste
wb1.Activate
With ws1
i = 7
Do Until .Cells(i, 2) = ""
Cells(i, 5).Value = Application.VLookup(Cells(i, 2).Value, lookuprng, 2, 0)
i = i + 1
Loop
End With
End Sub