+ Reply to Thread
Results 1 to 14 of 14

Combine Two Similar Private Subs

  1. #1
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Question Combine Two Similar Private Subs

    Hello,

    I need to add this code from Sheet 2 of my workbook:

    Please Login or Register  to view this content.
    ..to this code on Sheet 1 of the same workbook:

    Please Login or Register  to view this content.
    What is the correct way of doing this so that both SelectionChange events will work? I'm trying to learn how.
    Last edited by swordswinger710; 02-27-2012 at 05:30 PM.

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combine Two Similar Private Subs

    Are you sure you want SelectionChange and not Change for the first code?
    Good luck.

  3. #3
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Combine Two Similar Private Subs

    Absolutely. See here on where I got it from and it's purpose.

  4. #4
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Combine Two Similar Private Subs

    Okay sweet, thank you - I'm still trying to see how you combined the two, apparently it's not just an easy matter of copying and pasting in the right location.

    And yes, I find it irritating as well! I still can't believe the fact that there's no way I'm not able to click once on a cell to check it, then click the same cell again to un-check it without having some other cell getting in the way, but oh well.

  5. #5
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combine Two Similar Private Subs

    That would be a double-click, no?

  6. #6
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Combine Two Similar Private Subs

    Technically, I guess so!

    So if I decided to go with this less annoying code instead:

    Please Login or Register  to view this content.
    ..how would that combine? I see you're adding tCell and rCell? Is there a standard way of combining formulas like these? I may have to do this to several more sheets in my workbook.

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combine Two Similar Private Subs

    I only used rCell because my version loops through the selected cells, in case you selected more than one of your target cells. If you won't be doing that, then your code is fine without the loop.

  8. #8
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Combine Two Similar Private Subs

    So if this..

    Please Login or Register  to view this content.
    ..plus this..

    Please Login or Register  to view this content.
    ..equals this:

    Please Login or Register  to view this content.
    ..then would this..

    Please Login or Register  to view this content.
    ..plus this..

    Please Login or Register  to view this content.
    ..equal.. this?

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Combine Two Similar Private Subs

    Hmpf. Apparently not as I'm getting errors with it.

  10. #10
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combine Two Similar Private Subs

    You have a superfluous End If at the end.

  11. #11
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Combine Two Similar Private Subs

    When I take that away, I get more errors.

  12. #12
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combine Two Similar Private Subs

    What errors?

  13. #13
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Combine Two Similar Private Subs

    If I do this:

    Please Login or Register  to view this content.
    I get this error- Haha, and now it works, of course. Wow. There is still one issue, however. I don't know how difficult the fix would be, but by clicking any of the cells listed in the second part of the code (A14, G14, or L14) the first part of the code (which requires a page number to be entered before any other cell gets data entered) gets bypassed and the checkbox cell gets changed. The Message Box does appear, but after clicking OK, the checkbox cell that was clicked changes.

    Is there something we can change to solve this?

  14. #14
    Forum Contributor swordswinger710's Avatar
    Join Date
    02-20-2008
    Location
    Bright, Canada
    MS-Off Ver
    2010
    Posts
    845

    Re: Combine Two Similar Private Subs

    Oh wow, that's fantastic! Thank you so much for all your help. Much appreciated!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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