UserForm help

jphina

New Member
Joined
Nov 20, 2021
Messages
9
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hey All,

I'm currently trying out userForms for the first time and I'm lacking knowledge as to how to have when I double click on a cell in range("D5:D26") for:
  • open the form and allow the user to select from the 3 choices
  • on choice "On" for it to turn the cell double-clicked green and leave the corresponding cell in E & F blank
  • on choice "Off" for it to turn the cell double-clicked red and for the corresponding cell in E & F to say closed
  • on choice "Intermittent" for it to turn the cell double-clicked orange and leave the corresponding cell in E & F blank
Probably a simple task, but I'm a bit confused on what the worksheet code or userform code should read. Any help would be greatly appreciated!
 

Attachments

  • Capture.PNG
    Capture.PNG
    33.1 KB · Views: 10
  • Capture1.PNG
    Capture1.PNG
    115.7 KB · Views: 11

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi,
try following & see if helps

Place following in your userforms code page

VBA Code:
Private Sub IntermittentButton_Click()
    With ActiveCell
        .Interior.Color = rgbOrange
        .Offset(, 1).Resize(, 2).Value = ""
    End With
End Sub

Private Sub OffButton_Click()
    With ActiveCell
        .Interior.Color = rgbRed
        .Offset(, 1).Resize(, 2).Value = "Closed"
    End With
End Sub

Private Sub OnButton_Click()
    With ActiveCell
        .Interior.Color = rgbGreen
        .Offset(, 1).Resize(, 2).Value = ""
    End With
End Sub

Place following in your WORKSHEETS code page

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Range("D5:D26")) Is Nothing Then UserForm1.Show
End Sub

Change the names of Userform & commandbuttons as required to meet your specific project need.

If new to userforms then suggest visit site like this: How to Create Excel UserForm for Data Entry
for some free very helpful guidance

Dave
 
Upvote 0
Solution
Hi,
try following & see if helps

Place following in your userforms code page

VBA Code:
Private Sub IntermittentButton_Click()
    With ActiveCell
        .Interior.Color = rgbOrange
        .Offset(, 1).Resize(, 2).Value = ""
    End With
End Sub

Private Sub OffButton_Click()
    With ActiveCell
        .Interior.Color = rgbRed
        .Offset(, 1).Resize(, 2).Value = "Closed"
    End With
End Sub

Private Sub OnButton_Click()
    With ActiveCell
        .Interior.Color = rgbGreen
        .Offset(, 1).Resize(, 2).Value = ""
    End With
End Sub

Place following in your WORKSHEETS code page

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Range("D5:D26")) Is Nothing Then UserForm1.Show
End Sub

Change the names of Userform & commandbuttons as required to meet your specific project need.

If new to userforms then suggest visit site like this: How to Create Excel UserForm for Data Entry
for some free very helpful guidance

Dave
Thank you Dave! Worked perfect :)
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,454
Members
448,898
Latest member
drewmorgan128

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top