Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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) |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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) |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro recorded... tabs & file names changed, macro hangs | Excel Worksheet Functions | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
how to count/sum by function/macro to get the number of record to do copy/paste in macro | Excel Programming | |||
macro to delete entire rows when column A is blank ...a quick macro | Excel Programming | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |