[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

run macro if cell = 0

Posted on 2015-01-20
12
Medium Priority
?
63 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 37

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 37

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 37

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 37

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 37

Accepted Solution

by:
Kimputer earned 2000 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 37

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

Technology Partners: 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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

829 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