If,Then,Else Macro
Dear Experts
I have an Auto_Open Macro using the If, Then, Else statement for each time I open the spreadsheet it gives me the msgbox of percent completed. Here is what I have so far and it works with one problem. If Range ("Schedule!L1") =0 or is blank I get the Debug window upon opening the spreadsheet. How do I write this macro to tell Auto_open to ignore L1 cell if it is less then 0, or = to 0 or is blank? Cell L1 is formatted for percentage. Sub Auto_Open() Dim Value1 As Integer Dim Value2 As Integer If Range("Schedule!L1") 0 Then Value1 = Worksheets("Schedule").Range("L1") * 100 Value2 = Worksheets("Schedule").Range("M1") * 100 MsgBox "YOUR JOB IS " & (Value1) & " % " & "DETAILED" & " AND " & (Value2) & " % " & "SHIPPED", vbInformation, "PERCENT COMPLETE" End If End Sub -- He4Giv (Dick) |
If,Then,Else Macro
Sub Auto_Open()
Dim Value1 As Integer Dim Value2 As Integer If Range("Schedule!L1") 0 Then Value1 = Worksheets("Schedule").Range("L1") * 100 Value2 = Worksheets("Schedule").Range("M1") * 100 MsgBox "YOUR JOB IS " & (Value1) & " % " & "DETAILED" & " AND " & (Value2) & " % " & "SHIPPED", vbInformation, "PERCENT COMPLETE" Else Exit Sub (or some other values and/or message) End If End Sub Mike F "He4Giv" wrote in message ... Dear Experts I have an Auto_Open Macro using the If, Then, Else statement for each time I open the spreadsheet it gives me the msgbox of percent completed. Here is what I have so far and it works with one problem. If Range ("Schedule!L1") =0 or is blank I get the Debug window upon opening the spreadsheet. How do I write this macro to tell Auto_open to ignore L1 cell if it is less then 0, or = to 0 or is blank? Cell L1 is formatted for percentage. Sub Auto_Open() Dim Value1 As Integer Dim Value2 As Integer If Range("Schedule!L1") 0 Then Value1 = Worksheets("Schedule").Range("L1") * 100 Value2 = Worksheets("Schedule").Range("M1") * 100 MsgBox "YOUR JOB IS " & (Value1) & " % " & "DETAILED" & " AND " & (Value2) & " % " & "SHIPPED", vbInformation, "PERCENT COMPLETE" End If End Sub -- He4Giv (Dick) |
If,Then,Else Macro
He4Giv wrote:
.. How do I .. ignore L1 cell .. Sub Auto_Open() Dim Value1 As Integer Dim Value2 As Integer If Range("Schedule!L1") 0 Then Value1 = Worksheets("Schedule").Range("L1") * 100 Value2 = Worksheets("Schedule").Range("M1") * 100 MsgBox "YOUR JOB IS " & (Value1) & " % " & "DETAILED" & " AND " & (Value2) & " % " & "SHIPPED", vbInformation, "PERCENT COMPLETE" End If End Sub I think you want If IsNumeric(Range("Schedule!A1")) Then If Range("Schedule!A1") 0 Then ' .. End If End If |
All times are GMT +1. The time now is 11:10 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com