# Dize Game

• ### Question

• I need some help to my Double Click funktion...

My code is.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, Range("D7,F7,H7,J7,L7,N7,P7,R7,T7,V7,X7,Z7")) Is Nothing Then Exit Sub ' koden virker i cellerne A1 til A10 ret til aktuel
Target.Interior.ColorIndex = 4
' celle Colour Green (4) By DoubleClick
End Sub

That Works..

But the function i look after is adding the Value there is in those cell To Cell "N2"

exampel when i doubleclick on D7 the value is send to N2 and if cell J7 is doubleclick then cell D2 and J7 is adding together

so the value is D7 + J7 = N2  (1 + 4 = 5)

The value in D7=1,F7=2,H7=3,J7=4,L7=5,N7=6,P7=7,R7=8,T7=9,V7=10,X7=11,Z7=12

Hope that was enough info

(it's to a Old Board Game with Dize Called (SHOT THE BOX)

Henrik1 Denmark

Monday, July 27, 2015 2:20 PM

• Are the cells locked and the sheet protected? That would also explain it.

I have sent you a sample workbook. When you receive it, save it to disk, preferably to a Trusted Location for Excel.

If there is a button Unblock, click it.

When you open the workbook, make sure that you enable macros.

Regards, Hans Vogelaar (http://www.eileenslounge.com)

• Marked as answer by Tuesday, July 28, 2015 12:55 PM
Tuesday, July 28, 2015 12:44 PM
• Change the code like this:

```    If Not Intersect(Target, Range("D7,F7,H7,J7,L7,N7,P7,R7,T7,V7,X7,Z7")) Is Nothing Then
If Target.Interior.ColorIndex = 4 Then
' If cell is green, then remove green color
Target.Interior.ColorIndex = xlColorIndexNone
' Subtract value of target from N2
Range("N2").Value = Range("N2").Value - Target.Value
Else
' Else color cell green
Target.Interior.ColorIndex = 4
' Add value of target to N2
Range("N2").Value = Range("N2").Value + Target.Value
End If
' Do not enter edit mode
Cancel = True
End If
End Sub```

Regards, Hans Vogelaar (http://www.eileenslounge.com)

• Marked as answer by Wednesday, July 29, 2015 7:48 PM
Wednesday, July 29, 2015 3:04 PM

### All replies

• Like this:

```Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("D7,F7,H7,J7,L7,N7,P7,R7,T7,V7,X7,Z7")) Is Nothing Then
' celle Colour Green (4) By DoubleClick
Target.Interior.ColorIndex = 4
' Add value of target to N2
Range("N2").Value = Range("N2").Value + Target.Value
End If
End Sub```

Regards, Hans Vogelaar (http://www.eileenslounge.com)

Monday, July 27, 2015 2:39 PM
• Ive got error in this Line
Range("N2").Value = Range("N2").Value + Target.Value

Henrik1

Tuesday, July 28, 2015 10:23 AM
• The most probable explanation is that either N2 or the cell being double-clicked contains a text value.

Regards, Hans Vogelaar (http://www.eileenslounge.com)

Tuesday, July 28, 2015 11:24 AM
• silly Question But if its Work in your Could you then send me your version to me at
Fam.christensen@minpost.eu

i have re check all cell options and i try everything nothing seems to work

Tuesday, July 28, 2015 11:51 AM
• Are the cells locked and the sheet protected? That would also explain it.

I have sent you a sample workbook. When you receive it, save it to disk, preferably to a Trusted Location for Excel.

If there is a button Unblock, click it.

When you open the workbook, make sure that you enable macros.

Regards, Hans Vogelaar (http://www.eileenslounge.com)

• Marked as answer by Tuesday, July 28, 2015 12:55 PM
Tuesday, July 28, 2015 12:44 PM
• It Works on your file and i see what is wrong in my file later
so thanks for your help so far...
Henrik
Tuesday, July 28, 2015 12:55 PM
• Yes why not....
my failor was :
make all cell i colomn start from Row 7 to 13 compilet to one cell for each colomn, have change it back so only cell

on row 7 change to a one large cell instead and now it Works on my own file

typical when try to make som thing easy ....

Thanks Again.

Tuesday, July 28, 2015 1:38 PM
• A Little Question Hans.

My Daughter ask me what,  if we have make an error (Doubleclick on wrong celle ) and want to Remove the value after a Double click

Is it Possibel to make it this way.

first time Double Click on cell  "D7=1,F7=2,H7=3,J7=4,L7=5,N7=6,P7=7,R7=8,T7=9,V7=10,X7=11,Z7=12" the value is added to cell N2

seconde time Double Click on Cell "D7=1,F7=2,H7=3,J7=4,L7=5,N7=6,P7=7,R7=8,T7=9,V7=10,X7=11,Z7=12" the value is Taken from cell N2

Henrik-1

Wednesday, July 29, 2015 2:48 PM
• Change the code like this:

```    If Not Intersect(Target, Range("D7,F7,H7,J7,L7,N7,P7,R7,T7,V7,X7,Z7")) Is Nothing Then
If Target.Interior.ColorIndex = 4 Then
' If cell is green, then remove green color
Target.Interior.ColorIndex = xlColorIndexNone
' Subtract value of target from N2
Range("N2").Value = Range("N2").Value - Target.Value
Else
' Else color cell green
Target.Interior.ColorIndex = 4
' Add value of target to N2
Range("N2").Value = Range("N2").Value + Target.Value
End If
' Do not enter edit mode
Cancel = True
End If
End Sub```

Regards, Hans Vogelaar (http://www.eileenslounge.com)

• Marked as answer by Wednesday, July 29, 2015 7:48 PM
Wednesday, July 29, 2015 3:04 PM
• THANK YOU SO MUCH.

its Work

your Regards From Henrik-1 In Denmark

Wednesday, July 29, 2015 7:48 PM