PDA

View Full Version : [SOLVED:] Help with intersect



oberti
12-09-2021, 07:45 AM
Hello, I am attaching my code with which I have a problem.

My problem is that with this code I open 2 files (and so far so good), when I insert the value "UT-E" in the source file, the various values are copied in a table in the second sheet.
The problem is that whatever I write in the "SOP" column after entering the letter, number or other, the code switches to displaying the second excel file. I, on the other hand, would like it to pass to the second worksheet only if I enter the word "UT-E"

I am attaching the 2 files ...... do not make fun of me .... it is trivial and maybe even long and incorrect

georgiboy
12-09-2021, 08:20 AM
Hi there,

Just had a quick look at your code and noted that it looks like you are opening the destination workbook 'destwb' before the part where you only want the code to fire if it gets passed a "UT-E" value.

everything before this line:

If xCell.Value = "UT-E" Then
Will fire everytime you put any character into the cell, in your code this includes opening the destination file. When you open a file it will switch to it as the new focus window.

Maybe you can move where the destwb is opened in the code or open this file with a seperate sub outside of the change event?

Hope this helps

oberti
12-09-2021, 11:36 PM
Hi there,

Just had a quick look at your code and noted that it looks like you are opening the destination workbook 'destwb' before the part where you only want the code to fire if it gets passed a "UT-E" value.

everything before this line:

If xCell.Value = "UT-E" Then
Will fire everytime you put any character into the cell, in your code this includes opening the destination file. When you open a file it will switch to it as the new focus window.

Maybe you can move where the destwb is opened in the code or open this file with a seperate sub outside of the change event?

Hope this helps


THANKS FOR SUGGESTION....it's working :)