Results 1 to 8 of 8

Thread: worksheet_change event to replace words

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2009
    Location
    England!
    Posts
    364

    worksheet_change event to replace words

    i have a worksheet that will continuously be populated with the Words "TRUE" & "FALSE", i need a change event to find these words each time the entered and just replace them

    So range is A1:R65536, "TRUE" would be changed to "YES" and "FALSE" would be changed to a blank cell.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: worksheet_change event to replace words

    I would not want to scan the entire column upon the change event. I would evaluate the Target passed in parameter object to determine if its the desired column and if so then I would do a replace on the active cell.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2009
    Location
    England!
    Posts
    364

    Re: worksheet_change event to replace words

    Ok so its a checkbox from a userform if the value is set true i want it to say yes unless if the value is set as false i dont want it to store a value.

  4. #4
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: worksheet_change event to replace words

    better u fill as "yes" instead of "true" to avoid changing after fill, how do u fill the cells from userform?
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2009
    Location
    England!
    Posts
    364

    Re: worksheet_change event to replace words

    Simple command line :

    vb Code:
    1. Sheets(3).range(nrow, lrow + 0).value = checkbox1.value

    But this just places the value true or false in the cell.

  6. #6
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: worksheet_change event to replace words

    just use a if statement
    Code:
    If checkbox1.value = True then
    Sheets(3).range(nrow, lrow + 0) = "Yes"
    End If
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2009
    Location
    England!
    Posts
    364

    Re: worksheet_change event to replace words

    Thank you bud, ill give it a whirl when i get home

  8. #8
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: worksheet_change event to replace words

    what is the use of adding 0 here?
    Code:
    Sheets(3).range(nrow, lrow + 0).value = checkbox1.value
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


Posting Permissions

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



Click Here to Expand Forum to Full Width