Using VBA to link 2 identical workbooks

EvilUeki

New Member
Joined
Aug 16, 2018
Messages
7
Basically, I have 2 identical workbooks with multiple sheets. (WorkbookA.xls and WorkbookB.xls) For each sheets there are some cells that are colored yellow within the same range (lets say A1:AA1000).

I would like to loop through every sheet in WorkbookA.xls and select all yellow colored cells, then make the formula for every yellow cells in WorkbookA.xls to be equal to the exact same cell in WorkbookB.xls ( so for example: WorkbookA.xls, sheet1, Cell A2, which is a yellow cell, the formula for it would be =[WorkbookB.xls]sheet1!A2 )

Any good suggestions on how to solve this?
Appreciate any help, thanks.
 
1. why do you say the code did not loop to the second sheet?

2. I don't understand how the book1 can have values. formulas are created to book2. Are the values NOT there before the code starts, and created directly as values? Is there any other code running somehow?

Not much help, I know. but I am at a loss to understand why the issues are occurring on what is simple code.

Are you able to do some debugging in the VBE?

And I'll be stopping for today very soon.
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Maybe strip it back to the basics. Basic yellow. two files both open. just 2 or 3 worksheets in each.
to eliminate other code running, toggle application.enableevents
check the initial values in both files.
step through one line at a time & see what happens

AND, I didn't code for matching yellow ranges in both files, just yellow cells in the file being updated

cheers
 
Upvote 0
Sorry...done some debugging and simplified the workbook a bit.... now it pretty much works out fine (i.e. the yellow cells in book1 is now linking to book2 through formula)

The only remaining problem is that..the code is not looping to the second sheet onwards. nothing happened in sheet2 or beyond.

Thank you so much for your help!
 
Upvote 0
1. why do you say the code did not loop to the second sheet?

2. why did the code not work & now it does (partially?)? how did the updated file have values and now has formulas? I think any problems are not with the code if applied to a simple set up. there are other things happening & I don't know about them

Can you test on a simple file and confirm the code works?
And then modify to suit whatever other set up you have?
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top