ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable Button (https://www.excelbanter.com/excel-programming/279053-disable-button.html)

Pete[_12_]

Disable Button
 
Hi, can anyone help me with a problem using excel macros?

I have a macro that will take away numbers from a value
that is provided in Cell A1. The problem is that when the
cell reaches Zero i would like to stop the button from
working. Because at the moment all i get is A1 going into
minus figures and that makes the rest of the spreadsheet
go wrong.

Thanks for looking.

Pete

Tom Ogilvy

Disable Button
 
Private Sub CommandButton1_Click()
if isnumeric(Range("A1").Value) then
if Range("A1").Value -1 < 0 then
Range("A1").Value = 0
CommandButton1.Enabled = False
Else
Range("A1").Value = Range("A1").Value - 1
End if
End if
End Sub

--
Regards,
Tom Ogilvy


"Pete" wrote in message
...
Hi, can anyone help me with a problem using excel macros?

I have a macro that will take away numbers from a value
that is provided in Cell A1. The problem is that when the
cell reaches Zero i would like to stop the button from
working. Because at the moment all i get is A1 going into
minus figures and that makes the rest of the spreadsheet
go wrong.

Thanks for looking.

Pete




Mike Fogleman

Disable Button
 
Pete,
Put a qualifier in the loop that subtracts the numbers so the macro will
end.
If Range ("A1").value=0 Then
Exit Sub


"Pete" wrote in message
...
Hi, can anyone help me with a problem using excel macros?

I have a macro that will take away numbers from a value
that is provided in Cell A1. The problem is that when the
cell reaches Zero i would like to stop the button from
working. Because at the moment all i get is A1 going into
minus figures and that makes the rest of the spreadsheet
go wrong.

Thanks for looking.

Pete




Pete[_12_]

Disable Button
 
Thank you very much for your replys thats helped me alot.
Thanks!


-----Original Message-----
Hi, can anyone help me with a problem using excel macros?

I have a macro that will take away numbers from a value
that is provided in Cell A1. The problem is that when

the
cell reaches Zero i would like to stop the button from
working. Because at the moment all i get is A1 going

into
minus figures and that makes the rest of the spreadsheet
go wrong.

Thanks for looking.

Pete
.



All times are GMT +1. The time now is 10:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com