+ Reply to Thread
Results 1 to 8 of 8

Combining two Worksheet_Change Events

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    80

    Combining two Worksheet_Change Events

    I have looked around and have not found a catch-all solution to combine two Worksheet_Change Events. I've looked around and found many specific instances that had specific solutions. I would really like to know how to do this if anyone could point me in the right direction.

    Here is my situation:
    I'm looking to combine the following two Worksheet_Change Events in the code of the attached doc.

    The Macros:
    Search Item - Based on category selection from a cell will: filter both columns and rows.
    Please Login or Register  to view this content.
    Add Item - Based on category selection from a cell will: go to the bottom of selected category, insert a new row and continue the formulas.
    Please Login or Register  to view this content.
    Attached is the workbook, each of these macros work independently as desired, on their own tabs. I need them combined on a single tab. This will make more sense if you take a look at the workbook.

    Any help at all would be great and I would vastly appreciate it. Thank you.

    p.s. - If there is a catch-all way to combine two Worksheet_Change Events I would REALLY like to know how do so. That way in the future if I need to do this again in another situation I would be able to. Any help in getting pointed in the right direction to learn that would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Combining two Worksheet_Change Events

    Hey Fett,

    Good to see you again.. See the attached file, is this what you're trying to accomplish? Like to allow you add categories just like that or even in the case when you have filter ON? Below is the consolidated one.

    Please Login or Register  to view this content.
    Please Note : The change in Find statement

    For this, I have made up another dynamic range so that I search for the string only where it should among the list of other cells in the sheet. Following is the formula for the named range starting from [B7].

    Please Login or Register  to view this content.
    Attached Files Attached Files
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  3. #3
    Registered User
    Join Date
    12-17-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Combining two Worksheet_Change Events

    codeslizer, once again, thank you very much for your wonderful help. This is exactly what I was looking for. Thank you!

  4. #4
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Combining two Worksheet_Change Events

    Glad to help!

  5. #5
    Registered User
    Join Date
    12-17-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Combining two Worksheet_Change Events

    Quote Originally Posted by codeslizer View Post
    ..... See the attached file, is this what you're trying to accomplish? Like to allow you add categories just like that or even in the case when you have filter ON? Below is the consolidated one. .....
    Hey codeslizer, thank you again for all your help. I was working with the code you sent me and I was attempting to add hiding columns to the search item code. When a category is selected not only would I need the rows filtered, but also only the columns that pertain to that category.
    Example:
    When Breaker is selected the only columns that should be displayed are A-I, K, L, AP, AZ-BK, BP.
    Columns needing to be displayed/hidden are different for each category.

    Is there a way to add in the option to select (in the code) which columns are displayed for each category?

    Perhaps a different way to explain it is:
    IF cell B4 (the cell I'm using to select the search criteria) = [value]
    THEN hide columns: _, _, _, _, .....

    I do not mind filling this information out in the code myself, but I don't know the syntax to do it properly. Could you advise me on how to set up just one, and I can set up the rest please?

    I apologize for not explaining this well enough before.

  6. #6
    Registered User
    Join Date
    12-17-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Combining two Worksheet_Change Events

    I tried this:
    Please Login or Register  to view this content.
    But it didn't work, I think I'm placing this in the code in the wrong location. I guess I don't know where it should go. Could you advise? Also, will this get me the results I'm looking for?

  7. #7
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: Combining two Worksheet_Change Events

    Hey buddy, tweaked a little in the code section. I hope you know Target is a cell reference that tells where exactly the event has occurred. Selection can be called its plural. In order to track the changes in B4 cell alias "vFilterBy", the cell address should match with the Target cell's address and there in our code we use
    Please Login or Register  to view this content.
    The first line of our code. It confirms and tells the processor that the change has occurred in B4 only, so.. do the following codes - like kind of thing. Following is a sample of how you can perform it. See re-worked attached file for working example.

    Please Login or Register  to view this content.
    P.S. I must say, its the first check condition in the above code. :P
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    12-17-2012
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    80

    Re: Combining two Worksheet_Change Events

    O K; I see it now. This has helped tremendously and I have learned quite a bit. Thank you for helping me and for sharing your knowledge. I appreciate it very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need help combining multiple Worksheet_Change events
    By rlbush2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2012, 04:51 PM
  2. [SOLVED] Merging Two Worksheet_Change Events
    By swordswinger710 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-04-2012, 04:18 PM
  3. Multiple worksheet_change events on one sheet
    By Hammer_757 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-02-2012, 03:10 PM
  4. WorkSheet_Change or Events
    By fsgg69 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-28-2010, 04:09 AM
  5. whats the maximum nr of Worksheet_Change events?
    By diepenbos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2006, 03:54 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1