Cell drag and drop game

dgrosen

Board Regular
Joined
May 3, 2003
Messages
110
Hi all. I am trying to develop an educational activity for my students in excel. With COVID we educators need to be more resourceful. The idea is to have a table where students drag and drop a text box with the answer into a cell. The final score is displayed once they drop the last text box. Any help on the right direction is very much appreciated
In the example below, students need to drag the box ”red” next to Apple. if they drop it in the right place they get a point.
thanks in advance.

vegetablecolorshape
Apple
Banana
redsquare
yellowround
bluetriangle
greenelongated
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hello Dgrosen,
here is one quick created code.
I hope so it will be enough to start...
VBA Code:
Option Explicit

Dim vNScore As Integer

Private Sub btnStart_Click()

    vNScore = 0
    Range("B2:C4").Clear
    Range("B6") = "red"
    Range("B7") = "yellow"
    Range("B8") = "blue"
    Range("B9") = "green"
    Range("C6") = "square"
    Range("C7") = "round"
    Range("C8") = "triangle"
    Range("C9") = "elongated"
    
End Sub

Private Sub btnShowResult_Click()
        
    If Not Range("B2") = "" And _
       Not Range("B3") = "" And _
       Not Range("C2") = "" And _
       Not Range("C3") = "" Then _
       MsgBox "Your final score is  " & vNScore
    
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Application.AlertBeforeOverwriting = False
    
    If Target.Address = "$B$2" And ActiveCell = "red" Then
        vNScore = vNScore + 1
        Exit Sub
    Else
        If Not Target.Row > 5 Then
            GoTo EX1
        End If
    End If
EX1:
     If Target.Address = "$B$3" And ActiveCell = "yellow" Then
        vNScore = vNScore + 1
        Exit Sub
    Else
        If Not Target.Row > 5 Then
            GoTo EX2
        End If
    End If
EX2:
     If Target.Address = "$C$2" And ActiveCell = "square" Then
        vNScore = vNScore + 1
        Exit Sub
    Else
        If Not Target.Row > 5 Then
            GoTo EX3
        End If
    End If
EX3:
  If Target.Address = "$C$3" And ActiveCell = "round" Then
        vNScore = vNScore + 1
        Exit Sub
    Else
        If Not Target.Row > 5 Then
            GoTo EX4
        End If
    End If
EX4:
   
End Sub
 
Upvote 0
Hello Dgrosen,
here is one quick created code.
I hope so it will be enough to start...
VBA Code:
Option Explicit

Dim vNScore As Integer

Private Sub btnStart_Click()

    vNScore = 0
    Range("B2:C4").Clear
    Range("B6") = "red"
    Range("B7") = "yellow"
    Range("B8") = "blue"
    Range("B9") = "green"
    Range("C6") = "square"
    Range("C7") = "round"
    Range("C8") = "triangle"
    Range("C9") = "elongated"
   
End Sub

Private Sub btnShowResult_Click()
       
    If Not Range("B2") = "" And _
       Not Range("B3") = "" And _
       Not Range("C2") = "" And _
       Not Range("C3") = "" Then _
       MsgBox "Your final score is  " & vNScore
   
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Application.AlertBeforeOverwriting = False
   
    If Target.Address = "$B$2" And ActiveCell = "red" Then
        vNScore = vNScore + 1
        Exit Sub
    Else
        If Not Target.Row > 5 Then
            GoTo EX1
        End If
    End If
EX1:
     If Target.Address = "$B$3" And ActiveCell = "yellow" Then
        vNScore = vNScore + 1
        Exit Sub
    Else
        If Not Target.Row > 5 Then
            GoTo EX2
        End If
    End If
EX2:
     If Target.Address = "$C$2" And ActiveCell = "square" Then
        vNScore = vNScore + 1
        Exit Sub
    Else
        If Not Target.Row > 5 Then
            GoTo EX3
        End If
    End If
EX3:
  If Target.Address = "$C$3" And ActiveCell = "round" Then
        vNScore = vNScore + 1
        Exit Sub
    Else
        If Not Target.Row > 5 Then
            GoTo EX4
        End If
    End If
EX4:
  
End Sub
This is perfect! Thanks a lot
 
Upvote 0

Forum statistics

Threads
1,226,466
Messages
6,191,188
Members
453,646
Latest member
BOUCHOUATA

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