Results 1 to 13 of 13

Thread: [RESOLVED] option button

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Resolved [RESOLVED] option button

    excel options
    i have three option button 29, 34, 32
    when i click 29 or column 34 column o(14:333) not enable to enter
    option 32 only column o (14:333) shoudl enable to enter
    coudl you provide the code in vba
    thanks

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: option button

    Private Sub OptionButton32_Click()
    If OptionButton1.Value = True Then cELLS.cOLUMNS [o2:O333] = "YES" ' how do mention the range here
    End Sub

    Private Sub OptionButton2_Click()
    If OptionButton2.Value = True Then cELLS.cOLUMNS [o2:O333] = "NO"
    End Sub

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: option button

    Is this what you want?

    Code:
    Private Sub OptionButton32_Click()
        If OptionButton1.Value = True Then Sheets("Sheet1").Range("O2:O333").Value = "YES"
    End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: option button

    Kool
    is that i can enter in the cell is it not

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: option button

    i am trying to do when i click the optionbutton it should allow to enter range 02: 0333
    but still failed
    If OptionButton1.Value = True Then Sheets("Sheet1").Range("O2:O333").enabled = "YES"

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: option button

    could anybody help this
    I am trying ot do when i click the option button it does not allow me to enter anything
    Private Sub OptionButton60_Click()
    Dim RngPST As Range
    Set RngPST = Sheets("Sheet1").Range("A14:A600")
    Sheets("Sheet1").Range("A14:A600").Value = ""
    End Sub

  7. #7
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: option button

    it does not allow me to enter anything
    1. Do you get any error messages?
    2. Is the worksheet protected?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: option button

    kool
    when i enter in the cell. the cell should not allow to enter anythign when i press option button

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: option button

    try recording a macro of protecting the range

    i guess you would have set protection off for all cells, then protection on for the specific range, then protect the worksheet, with or without password

    you can try like this

    vb Code:
    1. Dim s As Worksheet
    2. Set s = Sheets("sheet1")
    3. s.UsedRange.Locked = False
    4. Range("o14:o333").Locked = True
    5. s.Protect "mypass"

    to allow access to those cells again just unprotect the sheet
    Last edited by westconn1; Mar 18th, 2010 at 03:49 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: option button

    Quote Originally Posted by kamakshi View Post
    kool
    when i enter in the cell. the cell should not allow to enter anything when i press option button
    Well in that case follow what Pete said.

    However remember that after you record the macro and if you password protect the worksheet using a password then the macro doesn't show the password so you will have to amend it accordingly for example

    Code:
    Activesheet.Protect "MyPassword"
    similarly to unprotect use this

    Code:
    Activesheet.UnProtect "MyPassword"
    Edit: Pete!!!!! Speedy Pete!!!! you beat me again...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: option button

    kool pete
    is the option button click or do i have to enter in worksheet change event.
    when us ther user enters in the cell and press enter or tab or page dpwn it should say the cell shoudl should be blank or when the option button click it should hide the cell and unhide . the cplumns contains validate rule for other option button

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: option button

    you can set the cells to locked (or hide) from the option button

    when locked excel gives some message when user tries to edit
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jun 2007
    Posts
    241

    Re: option button

    Westconn and kool thanks it works

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