Link to home
Start Free TrialLog in
Avatar of Jagwarman
Jagwarman

asked on

run macro if cell = 0

I'm sure it's simple but........

If Sheets("Static") D9 = 0

run macro called  send mail

Thanks
Avatar of Kimputer
Kimputer

I assume this code has to check that cell automatically without interaction (other than editing the sheet as usual)? Or you want this code to only run when you start another macro?
Avatar of Jagwarman

ASKER

On sheet NDPP there are tick boxes that enter time and user id off back of a macro. So when that runs and populates time and user Id then check D9 in static
For now, this will work for sure (please test it, only a message box will pop up though, that's intended for now)

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If (Target.Worksheet.Name = "Static") And (ActiveSheet.Cells(9, 4).Value = 0) Then
        'mail code
        msgbox ("mail code")
    End If
End Sub

Open in new window


Code belongs to ThisWorkBook in the VBA editor btw, otherwise it won't work.

After you're satisfied the pop up pops up when it should, we can continue with the mail code (Use outlook? Use smtp?)
should this go into a specific module or sheet. I put it in a module, did not work, I put it in Thisworkbook, still did not work, I put it in Sheet3 (Static) still did not work
Should be in Thisworkbook.

Messagebox ONLY shows when you go the sheet Static, and FILL in 0 in D9
Try that first. Really type it in with the keyboard, don't use the tickboxes and what not you have programmed.
it works if I key in manually
Okay, that's one step more. Can you tell me what's inside D9? Probably some formula?
Also, how do you intend to send the email, directly smtp or through outlook?
Hi kimputer.

=SUM(D5:D8) is in D9

Regards
ASKER CERTIFIED SOLUTION
Avatar of Kimputer
Kimputer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have the code for running the e-mail from Lotus notes so once I get this part to work it will be fine.

I have attached a file which should explain. When you tick box time and name appear. Static sheet is updated.
Checklist.xlsm
I just checked, my updated code works. It means, just copy & paste your working email code, replace the messagebox line.
Perfect thanks for all your help