+ Reply to Thread
Results 1 to 13 of 13

I'm trying to combine two worksheet event changes or at least get both to work somehow....

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    7

    I'm trying to combine two worksheet event changes or at least get both to work somehow....

    Hello all!

    First post! I've been lurking around here for a while and I think you people are all incredible. I've learned a lot so far.

    So here is my question. I have two event changes for a single sheet. The first event change allows me to enter multiple items in the same cell from picking from a drop down list. Here it is:

    Please Login or Register  to view this content.
    The second piece makes a DTPicker invisible when the cell that contains it is not selected. Here it is:
    Please Login or Register  to view this content.
    Now I know my code is not sophisticated and repetitive so please forgive me.

    Someone gave the idea of doing the following:

    Please Login or Register  to view this content.
    But still only the DTPicker code works. Anyone have any ideas? I won't be able to check your responses for a little while but will be back as soon as I can!

    Thanks!

  2. #2
    Registered User
    Join Date
    07-24-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    bump? Any help is much appreciated!

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    Hi krosenest and welcome to the forum,

    Try changing the ByVal to ByRef and see what happens.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    07-24-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    Should I change it in both?

  5. #5
    Registered User
    Join Date
    07-24-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    Compile Error:

    Procedure declaration does not match description of event or procedure having the same name...

    Thoughts?

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    Ok - On Change is different than On Selection Change.
    To trigger an On Selection Change you simply need to click in that cell... I'd suggest your DTPicker code look like...
    Please Login or Register  to view this content.
    Change my MsgBox with your picker code.

    Having multiple Events for the same sheet isn't a problem if your code is correct.

    In looking at your top code I don't see why you want "multiple items in the same cell". Are you doing the multiple items from a list control?

    In short, I guess I need to see a sample of the worksheet to understand the problem and then I can step through the code with the sheet and try to help more.

  7. #7
    Registered User
    Join Date
    07-24-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    Thanks for your response. Here is what I put in:

    Please Login or Register  to view this content.
    Unfortunately this caused both codes (the DT picker and multiple input from drop down) to not work.

    Am I doing something wrong?

    Also, It's important to have the ability to choose multiple items from a drop down list because in that drop down are "estimate numbers" that apply to a certain item listed to the right in it's respective row. Multiple estimate numbers apply to each item and rather than rely on the user to remember the estimate numbers they can choose from I chose to have a drop down menu there for them to use.

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    I don't have DTPicker on my machine but you should only need to have a single one of them open up. When you close DTPicker you will put the selected date back in the Target cell. This will reduce your long second sub of code.

  9. #9
    Registered User
    Join Date
    07-24-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    I have multiple DT pickers because there is one item in each row that require two dates. Since each DTpicker can only link to one cell (at least as far as I know) I had to have multiple. Any idea on how to combine the two change events even though they are for selection and change? I've read in multiple places that only one change event can exist in a worksheet which is the level that the code is at. If I remove either sub the other works fine. It's when both are present that they don't work.

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    Selection_Change is triggered when you click or move to a new cell. Change is triggered when a value is changed in a cell on the entire worksheet.

    You can use the Change trigger and test to see if it is in either range like:
    Please Login or Register  to view this content.
    The above tests two different ranges for a single Worksheet_Change event. Does this help?

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    As for multiple DTPickers, I remember building a single UserForm and putting a single DTPicker on it. The code would open that Userform which would open the DTPicker. When the Userform is closed the value of the DTPicker is put back in the Target Cell. I don't think you need multiple DTPickers on your sheet and can reduce your code using a single one on a UserForm.

    OF COURSE, all this takes some VBA user knowledge/experience (which you are gaining).
    See if this helps http://www.office-forums.com/dtpicker-t1984552.html

  12. #12
    Registered User
    Join Date
    07-24-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    So when I entered in the code you gave me and kept all the other code already there I got the 'message in column b' but couldn't get the 'you hit dtpicker range'. Where should I go from here? I'm sorry I'm not easy to help.

  13. #13
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,384

    Re: I'm trying to combine two worksheet event changes or at least get both to work somehow

    So here is the deal. Because the Event is a Worksheet_Change, you need to change something for it to trigger. If you put your cursor in one of the cells defined for the DTPicker (Try C2) and type a simple space and then hit enter, you should see the DTPicker message box.

    In the code before I had the DTPicker tied to a Worksheet_SelectionChange event which triggers whenever you simply click on a different cell on that worksheet.

    Here is the bible on Events http://www.cpearson.com/excel/Events.aspx (Microsoft Sites are more exact but this is a great start)

    Do you want the code to be run when you click on a cell (Worksheet_SelectionChange) or when the data in a cell is changed (Worksheet_Change)?

+ 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. Replies: 3
    Last Post: 02-22-2013, 11:28 AM
  2. How to have a Worksheet Change event Work if a cell says "ON"
    By trickyricky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2011, 10:07 PM
  3. Worksheet change event doesn't work properly
    By ffandango in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-05-2009, 06:03 PM
  4. Replies: 5
    Last Post: 06-23-2005, 06:05 PM
  5. worksheet change event doesn't work
    By gig in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2005, 11:06 AM

Tags for this Thread

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