+ Reply to Thread
Results 1 to 8 of 8

Multiple Private Sub Worksheet_Change(ByVal Target As Range)

  1. #1
    Registered User
    Join Date
    03-16-2024
    Location
    Ontario, Canada
    MS-Off Ver
    365 Office
    Posts
    2

    Multiple Private Sub Worksheet_Change(ByVal Target As Range)

    Hello,

    I am trying to learn how to combine two set of Private Sub on a same worksheet.

    Here is my codes:
    Please Login or Register  to view this content.
    It compiles but has no result from either range entry for EntryDate or RecvDate.
    What is my problem? All help and suggestion are appreciated. Thank you
    Last edited by AliGW; 03-24-2024 at 02:45 AM. Reason: Code tags added - please review the forum guidelines.

  2. #2
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,423

    Re: Multiple Private Sub Worksheet_Change(ByVal Target As Range)

    pls try this code

    Please Login or Register  to view this content.
    Last edited by wk9128; 03-24-2024 at 03:00 AM.

  3. #3
    Registered User
    Join Date
    03-16-2024
    Location
    Ontario, Canada
    MS-Off Ver
    365 Office
    Posts
    2

    Re: Multiple Private Sub Worksheet_Change(ByVal Target As Range)

    Hello wk9128,

    Thank you for your help. It works like a charm. Do mind to elaborate why my codes did not work so that I can understand ? Thanks

  4. #4
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,423

    Re: Multiple Private Sub Worksheet_Change(ByVal Target As Range)

    @MeMikeExcel You're Welcome. Glad to help . Thank You for the feedback.


    If you finally get a solution please mark your thread as SOLVED:
    - Click Thread Tools above your first post,you will see the word PREFIX on the upper left, press the button to select [SOLVED] select "Mark your thread as Solved".
    - you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help
    was given. By doing so you can add to the reputation(s) of those who helped.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Multiple Private Sub Worksheet_Change(ByVal Target As Range)

    Quote Originally Posted by MeMikeExcel View Post
    Do mind to elaborate why my codes did not work so that I can understand ?
    In your code, you first check for the condition that the Target cell (the cell that was changed, causing this sub to run) is in column A, which you have named EntryDate. If this condition is not True, then your code does an Exit Sub. Therefore the rest of the code is never run. It never gets to the check to see if Target is in column AD (RecvDate).

    However, it should work when Target is in column A.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  6. #6
    Valued Forum Contributor
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    2021
    Posts
    302

    Re: Multiple Private Sub Worksheet_Change(ByVal Target As Range)

    ...and:
    Please Login or Register  to view this content.
    NOTE: As the original poster/owner, only you can mark your thread as SOLVED (Thread Tools above Post #1).
    You can say "Thanks" in your thread to everyone who offered to help you.
    You can also reward them by clicking * "Add Reputation" under their username on the left.
    With Regards, MikeVol.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Multiple Private Sub Worksheet_Change(ByVal Target As Range)

    This is the best practice, although declaring EntryDate without a type, or not declaring it at all, will default to Variant. That is not what's causing that code to fail.

  8. #8
    Valued Forum Contributor
    Join Date
    12-30-2020
    Location
    Odessa / Ukraine
    MS-Off Ver
    2021
    Posts
    302

    Re: Multiple Private Sub Worksheet_Change(ByVal Target As Range)

    I know that this is not an error for a procedure failure. But, as you yourself said: for best practice. Good luck!

+ 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. Private Sub Worksheet_Change(ByVal Target As Range)
    By PIM499 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2019, 01:07 AM
  2. [SOLVED] Private Sub Worksheet_Change(ByVal Target As Range)
    By TheTallOne in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-28-2018, 11:19 AM
  3. Running multiple 'Private Sub Worksheet_Change(ByVal Target As Range)' in one
    By jankrulak in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-11-2018, 07:05 AM
  4. [SOLVED] Combining multiple Private Sub Worksheet_Change(ByVal Target As Range)
    By victortan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2014, 11:12 AM
  5. [SOLVED] Private Sub Worksheet_Change(ByVal Target As Range) End Sub
    By kanonathena in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2013, 12:25 AM
  6. [SOLVED] Private Sub Worksheet_Change(ByVal Target As Range)
    By Arturo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-25-2005, 11:06 AM
  7. Private Sub Worksheet_Change(ByVal Target As Range)
    By bondcrash in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-11-2005, 02:59 PM

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