Fwafa
Fwafa

Reputation: 107

Copy and paste between workbooks

This is a question and may or may not be achievable but any recommendation is much appreciated.

Is it possible to have one workbook (wrkbookA) open that has all the data and vba code in it. Click button to open/navigate to a directory and select another workbook (wrkbookB). wrkbookB is opened, select a column, that column is copied and pasted into wrkbookA in column A and wrkbookB is closed.

I know this can be achieved using a constant column from wrkbookB but the data is in differnet columns in each workbook in wrkbookB.

I have also looked at column headings and doing the copy that way but it is not an option as there are different columns with similar heading/words.

Thanks everyone.

Upvotes: 1

Views: 564

Answers (1)

John Bustos
John Bustos

Reputation: 19544

Since you don't have any way of knowing which Column will need to be selected from workbook B, you're going to need user interaction. that being the case, why not write a sub that will do the following:

  1. Have user select workbook B to open
  2. Place a button in Workbook B attached to code in Workbook A

User then, in Workbook B, selects the column they want copied and push the button which copies that column to Workbook A and closes Workbook B without saving changes.

Sample Code Idea:

Workbooks.Open ...
ActiveSheet.Buttons.Add(427.5, 12.75, 104.25, 36).OnAction = "WorkBookA!MoveColumn"

Upvotes: 1

Related Questions