Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA IF QUESTION
I have this formula in vba:
If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True It works fine and prints but it prints even if the cell is zero. What am I doing wrong. I only need it to print the range if c28 is greater than zero. Please help. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA IF QUESTION
when you have code on the same line as the THEN it is the only part of the
code that is checked If Range("C28") 0 Then _ Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True end if "Hamed parhizkar" wrote: I have this formula in vba: If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True It works fine and prints but it prints even if the cell is zero. What am I doing wrong. I only need it to print the range if c28 is greater than zero. Please help. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA IF QUESTION
Don't put the continuation line after the then. I caught the mistake just
when I press the reply button as the window was closing. from then _ to then "Hamed parhizkar" wrote: I have this formula in vba: If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True It works fine and prints but it prints even if the cell is zero. What am I doing wrong. I only need it to print the range if c28 is greater than zero. Please help. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA IF QUESTION
Change to following:-
If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True end if "Hamed parhizkar" wrote in message ... I have this formula in vba: If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True It works fine and prints but it prints even if the cell is zero. What am I doing wrong. I only need it to print the range if c28 is greater than zero. Please help. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA IF QUESTION
So what is the formula suppose to look like, I dont have a _ in there?
If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True "Joel" wrote: Don't put the continuation line after the then. I caught the mistake just when I press the reply button as the window was closing. from then _ to then "Hamed parhizkar" wrote: I have this formula in vba: If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True It works fine and prints but it prints even if the cell is zero. What am I doing wrong. I only need it to print the range if c28 is greater than zero. Please help. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA IF QUESTION
Sub printif()
If Range("c28") 0 Then Range("a23:d34").Printout 'Preview End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Hamed parhizkar" wrote in message ... I have this formula in vba: If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True It works fine and prints but it prints even if the cell is zero. What am I doing wrong. I only need it to print the range if c28 is greater than zero. Please help. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA IF QUESTION
It should look like this...
If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True End If Whenever you have multiple statements that, as a group, will only be executed for a given logical condition, you put all the multiple statements between an If-Then statement (with nothing following the Then) and an End If statement. Rick "Hamed parhizkar" wrote in message ... So what is the formula suppose to look like, I dont have a _ in there? If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True "Joel" wrote: Don't put the continuation line after the then. I caught the mistake just when I press the reply button as the window was closing. from then _ to then "Hamed parhizkar" wrote: I have this formula in vba: If Range("C28") 0 Then Range("A23:D34").Select ActiveSheet.PageSetup.PrintArea = "$A$23:$D$34" ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True It works fine and prints but it prints even if the cell is zero. What am I doing wrong. I only need it to print the range if c28 is greater than zero. Please help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|