Solved

run macro if cell = 0

Posted on 2015-01-20
12
58 Views
Last Modified: 2015-01-21
I'm sure it's simple but........

If Sheets("Static") D9 = 0

run macro called  send mail

Thanks
0
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 36

Expert Comment

by:Kimputer
ID: 40559948
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?
0
 

Author Comment

by:Jagwarman
ID: 40559960
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
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 40559970
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?)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Jagwarman
ID: 40559994
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
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 40560056
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.
0
 

Author Comment

by:Jagwarman
ID: 40560338
it works if I key in manually
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 40560510
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?
0
 

Author Comment

by:Jagwarman
ID: 40561459
Hi kimputer.

=SUM(D5:D8) is in D9

Regards
0
 
LVL 36

Accepted Solution

by:
Kimputer earned 500 total points
ID: 40561463
Okay, I think you are working on another sheet (so the "Static" sheet D9 will be changed to 0 in the "background"?)
Here's other code:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If (ActiveWorkbook.Sheets("Static").Cells(9, 4).Value = 0) Then
        'mail code
        MsgBox ("mail code")
    End If
End Sub

Open in new window


For now, it works if you input in another sheet. If you input in a whole other Excel file, it probably won't work.
0
 

Author Comment

by:Jagwarman
ID: 40561486
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
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 40561514
I just checked, my updated code works. It means, just copy & paste your working email code, replace the messagebox line.
0
 

Author Comment

by:Jagwarman
ID: 40561541
Perfect thanks for all your help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question