moogthemoog
Board Regular
- Joined
- Nov 17, 2004
- Messages
- 51
Hi
I have a suggestions log, and I would like to keep a track of Likes and Dislikes.
I have an Excel table with a specific column to vote, but entering "L" or "D" (for Like and Dislike). I have code which will tally this up and identify net Like or Dislike.
However, to call this macro, I'm trying to use a Worksheet_Change event. This only appears to work when the user enters L or D by pressing Return.
If the user uses the cursor to navigate away from the cell (having typed L or D but not pressing Return), then the code doesn't work.
So I have also added in a Worksheet Selection change event:
However, the macro is only called if, when I type L then navigate Cursor Down, I immediately navigate Cursor Up to the cell.
I'd prefer to use an ActiveX Control (radio button) to vote for each suggestion, but this would presumably need a radio button on each table row (and I'd have to come up with code to add the radio button each time a new row is added to the table; and to delete the radio button if a table row is deleted).
Please can someone advise where I'm going wrong?
Thanks
Jon
I have a suggestions log, and I would like to keep a track of Likes and Dislikes.
I have an Excel table with a specific column to vote, but entering "L" or "D" (for Like and Dislike). I have code which will tally this up and identify net Like or Dislike.
However, to call this macro, I'm trying to use a Worksheet_Change event. This only appears to work when the user enters L or D by pressing Return.
If the user uses the cursor to navigate away from the cell (having typed L or D but not pressing Return), then the code doesn't work.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo ErrHandler
If Intersect(Target, Range("Table1[[#Data],[Vote Like or Dislike]]")) Is Nothing Then Exit Sub
If Target.Text = "L" Or Target.Text = "D" Then Call Voting
ErrHandler:
Application.EnableEvents = True
Exit Sub
End Sub
So I have also added in a Worksheet Selection change event:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
On Error GoTo ErrHandler
If Intersect(Target, Range("Table1[[#Data],[Vote Like or Dislike]]")) Is Nothing Then Exit Sub
If Target.Text = "L" Or Target.Text = "D" Then Call Voting
ErrHandler:
Application.EnableEvents = True
Exit Sub
End Sub
However, the macro is only called if, when I type L then navigate Cursor Down, I immediately navigate Cursor Up to the cell.
I'd prefer to use an ActiveX Control (radio button) to vote for each suggestion, but this would presumably need a radio button on each table row (and I'd have to come up with code to add the radio button each time a new row is added to the table; and to delete the radio button if a table row is deleted).
Please can someone advise where I'm going wrong?
Thanks
Jon