Search code examples
excelratingvba

Let the user to give star rating


I wonder if anyone could help me with a star rating of a specific row in Excel not based on any give number or any information, just based on the user idea, some thing like most websites use to collect feedback from their clients. Then a user could give one to five stars to a written content in a row.


Solution

  • I have made a little excel-file example that is attached. also a little code .

    See code below:

    Option Explicit
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Target.Count > 1 Then Exit Sub
        If Not Intersect(Target, Range("H2:L8")) Is Nothing Then
            Range("H2:L8").Rows(Target.Row - 1).Font.ColorIndex = xlAutomatic
            Range("H2:H8").Rows(Target.Row - 1).Resize(1, Target.Column - Range("H2").Column + 1).Font.ColorIndex = 6
        ElseIf Not Intersect(Range("G2:G8"), Target) Is Nothing Then
            ' No stars
            Target.Offset(0, 1).Resize(1, 5).Font.ColorIndex = xlAutomatic
        End If
    
    End Sub
    

    See attached file
    Here is my Excelfile

    Have a nice day