I have a macro that takes a range of cells from my current workbook, opens a specific workbook, pastes the cells into that workbook, saves and closes. This works just fine.
As this macro is applied to multiple workbooks i need it to paste into a worksheet dependent on information from the 1st workbook.
i.e
Open destination workbook2
look for worksheet called the value of workbook1/sheet1/cellA1
if it is not there then create a new worksheet called the value of workbook1/sheet1/cellA1
it is there then contiue with my paste&save macro
Here is my macro so far:
Sub copy_paste()
Dim firstbook As Workbook
Set firstbook = ThisWorkbook
firstbook.Sheets("sheet1").Select
Range("b5:e40").Cells.Copy
Workbooks.Open Filename:="P:string\workbook2.xls"
Sheets("sheet3").Range("b3").Cells.PasteSpecial xlPasteValuesAndNumberFormats
Workbooks("workbook2.xls").Save
Workbooks("workbook2.xls").Close
End Sub
As this macro is applied to multiple workbooks i need it to paste into a worksheet dependent on information from the 1st workbook.
i.e
Open destination workbook2
look for worksheet called the value of workbook1/sheet1/cellA1
if it is not there then create a new worksheet called the value of workbook1/sheet1/cellA1
it is there then contiue with my paste&save macro
Here is my macro so far:
Sub copy_paste()
Dim firstbook As Workbook
Set firstbook = ThisWorkbook
firstbook.Sheets("sheet1").Select
Range("b5:e40").Cells.Copy
Workbooks.Open Filename:="P:string\workbook2.xls"
Sheets("sheet3").Range("b3").Cells.PasteSpecial xlPasteValuesAndNumberFormats
Workbooks("workbook2.xls").Save
Workbooks("workbook2.xls").Close
End Sub