Solved

run macro if cell = 0

Posted on 2015-01-20
12
56 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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
 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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