Value Divide and set in cell

Hjemmet

Board Regular
Joined
Jun 20, 2018
Messages
207
Hey
is this possibel in VBA code

if i have a Empty cell ("F16") then Value from ("F15") is Divide with "2" But if value in ("F15") is Odd then Add +1 to value in ("F15") and then Divide with 2 and then Value is Put into Cell("F16") is that Possibel

i have look and search around Google but didn Find any solution about it


the same function should work in Colomn "F" to "R" on Row "16"

And if cell Empty ("F19") then Value from ("F18") is Divide with "2" But if value in ("F19") is Odd then Add +1 to value in ("F18") and then Divide with 2 and then Value is Put into Cell("F19")

this is the code i have in My workbook for other cell's

Code:
[/COLOR]Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)    
    
    If Target.Value = "" Then
   Range("F15").Value = Target.Value / 2


ElseIf Target.Value = "41" Then
   Range("16").Value = "41"


    
    On Error Resume Next
    If Not Intersect(Target, Range("F10:R19")) Is Nothing Then
        If Target.Value Mod 2 = 1 Then Target.Value = Target.Value + 1
      'Target.Value = Target.Value + 1
      'Range("F10").Value = Range("F10").Value + 1
            Target.Value = Target.Value / 2
      Cancel = True
    End If
    End If
End Sub


[COLOR=#333333]
 
Last edited:

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
You can describe with an example what you need.


For example, if in cell F15 you have the number 7, where do you press double click, in cell F15 or in cell F16?
Then 7 + 1 equals 8, 8 / 2 equals 4.


In which cell do you want 4?
 
Upvote 0
Okay.

Common notice for all Cell from F10 to F 19 is score with 3 Dart’s in each Cell

Start in Colomn “F” from Row “10” to Row “19”.

First 3 darts going after Field 15 and hit target with 2 dart’s give Score 30 for “F10”

Next 3 darts going after field 16 and hit target with 3 dart’s give score 48 for “F11”

Next 3 dart’s going after The Double field and if double is hit then score

And so on trough all cell

Trough game

But where
Cell “F16” should be “41” and if not then value from “F15” should bed Divide with 2
Depend on Odd so if value is odd then ad 1. ( example if value is 89 then ad 1 so value is 90)

And the divide value is set in “F16”

Further trough game until last cell “F19”

If field not hit then value in”F18” divide with 2 and depend on Odd so if value is odd then ad 1. (Example if value is 231 then ad 1 so value is 232)

And the divide value set in “F19”


Hope that was enough info

I cant put file with this message because im on Job
 
Upvote 0
Now I am more confused.
You can explain step by step what you need.

The double click event is necessary?

You could upload a copy of your file to a free site such www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Last edited:
Upvote 0
Code:
https://www.dropbox.com/s/vx6zx9d0ipkvh2c/Woodchupper.xlsm?dl=0

Her a file with Info on Sheet1 and Sheet2 is main sheet....
 
Upvote 0
Check the following, it works only for cells F16 and F19. If you want it to work for all cells change "F16, F19" by "F16:F19"

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  If Not Intersect(Target, Range([COLOR=#ff0000]"F16, F19"[/COLOR])) Is Nothing Then
    n = Target.Offset(-1)
    If n Mod 2 <> 0 Then n = n + 1
    Target.Value = n / 2
    Cancel = True
  End If
End Sub
 
Upvote 0
:cool: I'm glad to help you. Thanks for the feedback.
 
Upvote 0
First of all Thanks for you time to help me

My mistake is that it seems that i descripe it wrong what happen or should happen depending on what happend in those different cell’s

So i try again with this exampl

If no score or score in cell “F10” then “0” if no score or if score then the amount of score
And that is the same For all Cell’s from “F10” to “R19”

And so on trough game
But my issue here is If i have score in “F10” (45) and no score in “F11” then value in “F10” Divide with 2 and that is the same for alle cell from”F10” to “R19”
(“ No score in Cell then divide”)
And take notice for odd value if value is odd the. Must add 1 before divide

Sorry if it is difficult

Life aint Difficult if you have the Solution
But sometime you have to open eyes to see it
 
Upvote 0
You can make the explanation step by step.
For example:
Step 1, I write 15 in cell F10
Step 2, double click on cell F11
Step 3, the result in cell F11 must be X.

That way describes each of the possible scenarios.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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