Cross posted at:
https://www.mrexcel.com/board/thread...sheet.1177007/
Reason:
No solution after a few days.
Hi,
I want a code that will browse for a file using a dialogue box.
After that I want to open the file. I do not want macros in this file to run (only if that's possible).
I run some codes when the workbook opens and I want to avoid that when I am opening it through this approach - that's triggering the open event from another workbook or using a code to open it. I was thinking of setting some global variables for that but I can't get the right way atm.
If I am able to open the file or workbook without running the scripts as described above, there are Worksheets that I want to match their names in both workbooks.
If they match, then I want to match or compare the contents or headers to see if they match as well.
If they match, then I want to copy from the file that I just opened into the workbook that I ran the code from.
Now let me describe my sheet names:
My sheets have the naming convention like:
PLAN 1
PLAN 2
PLAN 3
CAT 1
CAT 2
OBJ
so if both workbooks have PLAN 1, then I want to check if the contents on B6:M6 are the same on both sheets.
If they match then I want to copy the data from the just opened workbook ( B7:N & last used row) and paste into the workbook that I ran the code from.
And I repeat the same logic for all the other sheets;
PLAN 2
PLAN 3
CAT 1
CAT 2
OBJ
Afterwards, I close the workbook that I copied from.
And that was what I posted at:
https://www.mrexcel.com/board/thread...sheet.1177007/
And after a careful reading and research about my problem, I have come to realized that I need to be a bit clearer about what I wanna achieve.
So in simple terms, what I want to achieve is to get the contents of one workbook copied into another workbook.
But in order not to get the wrong contents into the destination workbook, that’s why I want to use the various criteria as described above.
That is, I want to check if the workbook that I am opening (source) contains these sheets:
PLAN 1
PLAN 2
PLAN 3
CAT 1
CAT 2
OBJ
Then do all those sheets have same values in these ranges
B6:M6
That is to say, is B6 on PLAN 1 sheet (source workbook) having the same header as B6 on PLAN 1 sheet (destination workbook)?
Then same analysis run for, C6 to M6 (PLAN 1 sheet), and same for the other sheets.
Once they pass that check, we proceed to copy as stated above.
And with the copying, I want to only copy data from the source if the range B7:M & last used row is not empty. If empty, we skip the copy for that particular sheet.
Now that I have expressed myself a bit clearer, I am confident that someone can pull me out.
I am ready for any solution that works. Thanks.
Bookmarks