drop down list for comment

timlh42

Board Regular
Joined
Sep 27, 2017
Messages
76
is there anyway to have a selection list to choose from instead of writing a comment in the comment box?

Here is what I would like to do:

If any cell in range H7:H37 , J7:J37, L7:L37 (which are populated by a validation list) is less than 5, then a comment box would pop up offering the following choices:

Too much time
Too late
Not enough teamwork
etc
etc
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,925
Office Version
2007
Platform
Windows
Create a userform with the following:




Put the following code in the userform

Code:
Public cel As String    'At the beginning of all the code


Private Sub CommandButton1_Click()
  If ComboBox1.Value = "" Or ComboBox1.ListIndex = -1 Then
    MsgBox "Select a choice"
    Exit Sub
  End If
  With Range(cel)
    If .Comment Is Nothing Then .AddComment
    .Comment.Visible = True
    .Comment.Text Text:=ComboBox1.Value
    .Comment.Shape.TextFrame.AutoSize = True
  End With
  Unload Me
End Sub


Private Sub CommandButton2_Click()
  Unload Me
End Sub
Put the following code in the events on the sheet.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("H7:H37, J7:J37, L7:L37")) Is Nothing Then
    If Target.Count > 1 Then Exit Sub
    If Target.Value = "" Then Exit Sub
    If Target.Value < 5 Then
      With UserForm1
        .cel = Target.Address
        .Show
      End With
    End If
  End If
End Sub
SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 

timlh42

Board Regular
Joined
Sep 27, 2017
Messages
76
I'm not sure what went wrong but I get this message






Create a userform with the following:




Put the following code in the userform

Code:
Public cel As String    'At the beginning of all the code


Private Sub CommandButton1_Click()
  If ComboBox1.Value = "" Or ComboBox1.ListIndex = -1 Then
    MsgBox "Select a choice"
    Exit Sub
  End If
  With Range(cel)
    If .Comment Is Nothing Then .AddComment
    .Comment.Visible = True
    .Comment.Text Text:=ComboBox1.Value
    .Comment.Shape.TextFrame.AutoSize = True
  End With
  Unload Me
End Sub


Private Sub CommandButton2_Click()
  Unload Me
End Sub
Put the following code in the events on the sheet.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("H7:H37, J7:J37, L7:L37")) Is Nothing Then
    If Target.Count > 1 Then Exit Sub
    If Target.Value = "" Then Exit Sub
    If Target.Value < 5 Then
      With UserForm1
        .cel = Target.Address
        .Show
      End With
    End If
  End If
End Sub
SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 

timlh42

Board Regular
Joined
Sep 27, 2017
Messages
76
Sorry about that. I keep getting a compile error. Method or data member not found
 

timlh42

Board Regular
Joined
Sep 27, 2017
Messages
76
Okay. I did get that resolved. I had 2 userforms created.

But now, I keep getting an object required error code

Any ideas?
 

timlh42

Board Regular
Joined
Sep 27, 2017
Messages
76
I think it might be looking for the list but there isn't one in the code. How would I add that?
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,925
Office Version
2007
Platform
Windows
You can put the complete error message and on which line of the macro it stops.
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
7,925
Office Version
2007
Platform
Windows
Within the userform, you must create a ComboBox with the name of ComboBox1.
You must also create in the userform 2 buttons, commandbutton1 and commandbutton2
 

Forum statistics

Threads
1,078,467
Messages
5,340,501
Members
399,379
Latest member
Ashrafkamal

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top