1000 to 0

DanKOzz

New Member
Joined
Aug 17, 2011
Messages
4
So this is what I'm trying to figure out...

For example, if I had 1000 in one cell and in the cell below it I enter =RANDBETWEEN(90,122)... then in the cell below that, I would like to see the answer be depleted to 0 by pressing the F9 key repeatedly. I want to keep this all to just 3 cells but no more than 5.

What do I need to do to make this happen?

A preemptive thank you
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
What does this "I want to keep this all to just 3 cells but no more than 5." mean?

Can you explain the purpose of what you are asking for?
 
Upvote 0
So not just 3 cells then. Gee, thanks for the confusing message.

You haven't answered my other question ... what is the purpose of what you are trying to do?
 
Upvote 0
I apologize for the confusion :(

What I am trying to do is make a text based RPG with excel. The part i'm stumped on is some of the combat elements of the game i'm trying to make. The 1000 represents a target being at full health. 0 is the goal i'm trying to meet, of course meaning the target is dead.

Hope that helps... Again, thank you very much for any help you can lend to me.
 
Upvote 0
So you might have this on your sheet:
Excel Workbook
AB
1Initial strength1000
2Attack depletion103
3Remaining strength0
Sheet



You could then have this in your sheet code area ( right-click sheet tab, and choose View Code ):
Code:
Private Sub Worksheet_Calculate()
    Application.EnableEvents = False
    If Range("B3").Value = "" Then
        Range("B3").Value = Application.Max(0, Range("B1").Value - Range("B2").Value)
    Else
        Range("B3").Value = Application.Max(0, Range("B3").Value - Range("B2").Value)
    End If
    Application.EnableEvents = True
End Sub
Sub reset_remaining_strength()
    Application.EnableEvents = False
    Range("B3").ClearContents
    Application.EnableEvents = True
End Sub
You'd reset B3 to blank by calling reset_remaining_strength macro.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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