ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Newbie stuck (https://www.excelbanter.com/excel-programming/335093-vba-newbie-stuck.html)

Danny Jurmann

VBA Newbie stuck
 
Hi folks,

I wonder if anyone can help. I have created a macro to create a message box
if the value of a cell is greater than 15 hours.

I have:-

sub flexi_hours_gained()
'Macro to give a message if the flexi time = 15:00

If Range ("Flexi_hours_gained")=0.625 then
MsgBox "15 hours is the maximum allowable flexi time gained"
End If
End Sub

So far so good, I run the macro and it works, but I need the message box to
appear automatically if the range value is 15 hours (0.625). The range
value is not entered but calculated and the cell is protected, part of a
protected sheet.

Anyone have any ideas? For the recortd I have been learning VBA for about 4
hours :-)

Thanks in advance,

Danny



ben

VBA Newbie stuck
 
put this code in the appropriate sheet module ie (sheet1, sheet2 etc...)



sub worksheet_change(byval target as excel.range)
'Macro to give a message if the flexi time = 15:00

If Range ("Flexi_hours_gained")=0.625 then
MsgBox "15 hours is the maximum allowable flexi time gained"
End If
End Sub


--
When you lose your mind, you free your life.


"Danny Jurmann" wrote:

Hi folks,

I wonder if anyone can help. I have created a macro to create a message box
if the value of a cell is greater than 15 hours.

I have:-

sub flexi_hours_gained()
'Macro to give a message if the flexi time = 15:00

If Range ("Flexi_hours_gained")=0.625 then
MsgBox "15 hours is the maximum allowable flexi time gained"
End If
End Sub

So far so good, I run the macro and it works, but I need the message box to
appear automatically if the range value is 15 hours (0.625). The range
value is not entered but calculated and the cell is protected, part of a
protected sheet.

Anyone have any ideas? For the recortd I have been learning VBA for about 4
hours :-)

Thanks in advance,

Danny





All times are GMT +1. The time now is 07:25 AM.

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