blackwolf8262
New Member
- Joined
- May 10, 2022
- Messages
- 2
- Office Version
- 2016
- Platform
- Windows
I'm very new to coding and trying to simplify a form to be filled out for work. Here is a screenshot of the cells:
Essentially, when "Yes" is selected, the box will turn green and have "Y", and when "No" is selected, the box is red with "N".
My current VBA code is
Unfortunately this form has about 40 rows, and I feel that copy and pasting these click options will make the code extremely long. I'm wondering if I can simply write a macro where instead of using
where it's a specific numbered cell, I can make it so that it chooses the cell directly on the right of the cell that contains the radio buttons. I previously tried using
but it would change the value of the cell to the right of a cell I had previously clicked (which could be anywhere on the sheet), and not the cell that was directly to the right of the cell containing the radio buttons.
Any help would be extremely appreciated.
Essentially, when "Yes" is selected, the box will turn green and have "Y", and when "No" is selected, the box is red with "N".
My current VBA code is
VBA Code:
Sub OptionButton1_Click()
Range("D4").Interior.ColorIndex = 4
Range("D4") = "Y"
End Sub
Sub OptionButton2_Click()
Range("D4").Interior.ColorIndex = 3
Range("D4") = "N"
End Sub
Sub OptionButton3_Click()
Range("D6").Interior.ColorIndex = 4
Range("D6") = "Y"
End Sub
Sub OptionButton4_Click()
Range("D6").Interior.ColorIndex = 3
Range("D6") = "N"
End Sub
Sub OptionButton5_Click()
Range("D7").Interior.ColorIndex = 4
Range("D7") = "Y"
End Sub
Sub OptionButton6_Click()
Range("D7").Interior.ColorIndex = 3
Range("D7") = "N"
End Sub
Unfortunately this form has about 40 rows, and I feel that copy and pasting these click options will make the code extremely long. I'm wondering if I can simply write a macro where instead of using
VBA Code:
Range("D6")
VBA Code:
Activecell.Offset(0,1).select
Any help would be extremely appreciated.