VBA Excel Form

Vani11

New Member
Joined
Sep 19, 2017
Messages
9
[h=2]Re: Restrict entry on certain cells based on multiple drop drop-down list[/h]******** id="google_ads_iframe_/22152718/MrExcel_InContent_0" title="3rd party ad content" name="google_ads_iframe_/22152718/MrExcel_InContent_0" width="300" height="250" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" style="border-width: 0px; border-style: initial; vertical-align: bottom;">*********>


Hi,

Would there be a way to link a dropdown list value to a user form? The appointment column "D" has drop-down list.

The drop-down list values are:
Confirmed
Rescheduled
Cancelled

If a user selects, "Rescheduled", a pop up form should appear to users to select the following checkboxes:

*Blood Test *Urinalysis * Blood Pressure

Next, when the user mouse over that row of data where the appointment is "rescheduled", it should show the checkbox which the user have selected.

Subject NameTypeResAppointmentIDTime
DM New0.30Confirmed156058:45 AM
0.00
0.00
0.00
0.00
0.00
0.00
0.00

<tbody>
</tbody>

 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
OK. Here's what I did.

I added a new UserForm with three checkboxes and a button. The checkboxes have captions of "Blood Test", "Urinalysis" and "Blood Pressure". The button is called "OkButton", has a caption of "OK" and has the following code associated with clicking it:

Code:
Private Sub OkButton_Click()

Me.Hide

End Sub

I called the form "RescheduledForm" and gave it a caption of "Rescheduled".

I then added a Worksheet_Change event handler for the sheet with the following code:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim commentText As String
Dim check As Control

If Target.Count = 1 And Target.Column = 4 Then
    Target.ClearComments
    If Target.Value = "Rescheduled" Then
        RescheduledForm.Show vbModal
        commentText = ""
        For Each check In RescheduledForm.Controls
            If TypeName(check) = "CheckBox" Then
                If check.Value Then
                    commentText = commentText & IIf(commentText = "", "", ", ") & check.Caption
                End If
            End If
        Next check
        If commentText <> "" Then Target.AddComment commentText
        Unload RescheduledForm
    End If
End If

End Sub

When the user changes a cell in column D to have the value "Rescheduled", the form is shown and the checkboxes can be selected before clicking OK. This then adds a comment to that cell so that when you mouse over it, you can see the checked values. Changing a cell in column D to anything other than "Rescheduled" clears the comments on the cell.

WBD
 
Upvote 0
Hi there!

Thanks you so much!

Would these codes work across all other columns indicated with Appointment?

Because columns with the header, "Appointment" already has drop-down list.

Vani
 
Upvote 0
To make it work on cells in any "Appointment" column then perhaps change this:

Code:
If Target.Count = 1 And Target.Column = 4 Then

To this:

Code:
If Target.Count = 1 And Target.Row > 1 And Cells(1, Target.Column).Value = "Appointment" Then

WBD
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

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