Results 1 to 5 of 5

Thread: In Excel Click check box = auto change row

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    1

    In Excel Click check box = auto change row

    Once an okay VB.NET user, now forgot everything about it! I think this is probably pretty easy but I can't remember where to begin. HELP!!!

    I have a very basic worksheet in Excel. When the user clicks a check box, I want the corresponding row to automatically change color. And, if possible, I would like the row to become protected when the check box is checked. Any help would be great!

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

    Re: In Excel Click check box = auto change row

    Welcome to the Forums.

    Easiest way to learn most objects in Office VBA is to record a macro doing the task you want to program. Then look at the generated code to see what objects are used and how. Then you can tweek it how you may need.
    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
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: In Excel Click check box = auto change row

    That was a wuss out if I ever saw one...

    Recorded macros over bloat the code.. this can actually be done in one line.. but I'll show the possibilities

    VB Code:
    1. ActiveCell.EntireRow.Interior.Color = vbBlue
    2. Range("A1").EntireRow.Interior.Color = vbBlue
    3. Range("D5").EntireRow.Interior.Color = RGB(0,0,255)

    All set the either the last selected cell or a direct range to blue interior
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

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

    Re: In Excel Click check box = auto change row

    Perhaps you need to read the entire post before you reply.

    Quote Originally Posted by RobDog888
    ...Then look at the generated code to see what objects are used and how. Then you can tweek it how you may need.
    I mentioned it as a way to learn what objects to use so you can write it yourself.

    Give a programmer code and hes employed for a day. Teach a programmer how to program and you have helped him to become employed for a lifetime.
    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

  5. #5
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: In Excel Click check box = auto change row

    Quote Originally Posted by RobDog888
    Give a programmer code and hes employed for a day. Teach a programmer how to program and you have helped him to become employed for a lifetime.
    Totally agree with your there..
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

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