Hi There,
I am new to VBA, I have tried to write the code below. However, it says object required. I am new, but I thought I had everything in place.
I essentially want the vba to take a value from a cell which is a sheet name in another document, take a column reference which is in cell H1. Then copy and paste a set data (C5:C28) into the sheet referenced and the column referenced (e.g. B2, C2, D2, E2 etc etc).
Sub Upload()
Dim SheetRef As String
Dim CellRef As String
Dim ColRef As String
Dim ActiveWbk As Workbook
Dim ClosedWbk As Workbook
Set ActiveWbk = ActiveWorkbook
Set SheetRef = ActiveWbk.Sheets("Team Sheet Workings").Range("D2")
Set ColRef = ActiveWbk.Sheets("Team Sheet Workings").Range("H1")
Set CellRef = ActiveWbk.Sheets("Team Sheet Workings").Range(ColRef)
ActiveWbk.Sheets("Team Sheet Workings").Range("C5:C28").Copy
Set ClosedWbk = Workbook.Open("/Users/A3/Downloads/7.xlsx")
ClosedWbk.Sheets(SheetRef).Range(CellRef).PasteSpecial xlPasteValues
End Sub
Any help would be really appreciated.
Tom
I am new to VBA, I have tried to write the code below. However, it says object required. I am new, but I thought I had everything in place.
I essentially want the vba to take a value from a cell which is a sheet name in another document, take a column reference which is in cell H1. Then copy and paste a set data (C5:C28) into the sheet referenced and the column referenced (e.g. B2, C2, D2, E2 etc etc).
Sub Upload()
Dim SheetRef As String
Dim CellRef As String
Dim ColRef As String
Dim ActiveWbk As Workbook
Dim ClosedWbk As Workbook
Set ActiveWbk = ActiveWorkbook
Set SheetRef = ActiveWbk.Sheets("Team Sheet Workings").Range("D2")
Set ColRef = ActiveWbk.Sheets("Team Sheet Workings").Range("H1")
Set CellRef = ActiveWbk.Sheets("Team Sheet Workings").Range(ColRef)
ActiveWbk.Sheets("Team Sheet Workings").Range("C5:C28").Copy
Set ClosedWbk = Workbook.Open("/Users/A3/Downloads/7.xlsx")
ClosedWbk.Sheets(SheetRef).Range(CellRef).PasteSpecial xlPasteValues
End Sub
Any help would be really appreciated.
Tom