Solved

run macro if cell = 0

Posted on 2015-01-20
12
53 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
  • 6
  • 6
12 Comments
 
LVL 35

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 35

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
 

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 35

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 35

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 35

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 35

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now