Consulting

Results 1 to 3 of 3

Thread: Help with intersect

  1. #1
    VBAX Newbie
    Joined
    Dec 2021
    Posts
    2
    Location

    Help with intersect

    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
    Attached Files Attached Files

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,190
    Location
    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
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    VBAX Newbie
    Joined
    Dec 2021
    Posts
    2
    Location
    Quote Originally Posted by georgiboy View Post
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •