Solved

run macro if cell = 0

Posted on 2015-01-20
12
54 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delete all words in cell more than 5 words 7 47
Help with excell ... 6 61
Hlookup formula help 14 19
Issues with DAX Calculated Columns 6 0
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
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.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

930 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

8 Experts available now in Live!

Get 1:1 Help Now