Hi everyone,
I cannot seem to be able to work with the GetOpenFilename on the following piece of code (PLbook is the workbook containing the macro)
Dim CApath As Variant
Dim PLbook As Variant
ThisWorkbook.Save
CApath = Application.GetOpenFilename(Title:="Close Allocation Model")
Set wbOpen = Workbooks.Open(CApath)
PLbook = Application.GetOpenFilename(Title:="Commercial Packed P&L")
ThisWorkbook.Save
Set wb2Open = Workbooks.Open(PLbook)
Workbooks(wb2Open).Sheets("Act Plant Exp").Cells(6, 2).Value = Workbooks(wbOpen).Sheets("Bag in Box").Cells(52, 14).Value
If I use wb2Open and wbOpen the code does not crash but it does not do what it is meant to do either, namely attribute the value of a cell in the CApath workbook to another cell in the PLbook.
If I try to use CApath and PLbook instead of wbOpen I get a Subscript out of range error.
If I open the files prior to running the macro and mention their name via Input box the code works but unfortunately my users find it too difficult.
Please lend a hand, I have seen my code crash in every possible way since working on this!
Many thanks,
Alex
I cannot seem to be able to work with the GetOpenFilename on the following piece of code (PLbook is the workbook containing the macro)
Dim CApath As Variant
Dim PLbook As Variant
ThisWorkbook.Save
CApath = Application.GetOpenFilename(Title:="Close Allocation Model")
Set wbOpen = Workbooks.Open(CApath)
PLbook = Application.GetOpenFilename(Title:="Commercial Packed P&L")
ThisWorkbook.Save
Set wb2Open = Workbooks.Open(PLbook)
Workbooks(wb2Open).Sheets("Act Plant Exp").Cells(6, 2).Value = Workbooks(wbOpen).Sheets("Bag in Box").Cells(52, 14).Value
If I use wb2Open and wbOpen the code does not crash but it does not do what it is meant to do either, namely attribute the value of a cell in the CApath workbook to another cell in the PLbook.
If I try to use CApath and PLbook instead of wbOpen I get a Subscript out of range error.
If I open the files prior to running the macro and mention their name via Input box the code works but unfortunately my users find it too difficult.
Please lend a hand, I have seen my code crash in every possible way since working on this!
Many thanks,
Alex