Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50004

[SOLVED] If statement to end sub or continue

$
0
0
I'm battling with my first VAB IF statement. If the value of cell F14 is <> 0, then display a msg box and exit the macro. If no value in F14 then to continue to print

Code:

    If Range("f14").Value <> 0 Then
    MsgBox ("This Certificate of Practical Completion has already been run")
   
    End If
   
    Application.ScreenUpdating = False
    Range("F14").Select
    Selection.Copy
    Range("AB2").Select
    ActiveSheet.Paste
    Application.ScreenUpdating = True
    Application.Wait Time + TimeSerial(0, 0, 2)
    Application.ScreenUpdating = False
    Sheets("Print_CC1").Select
    Range("B2").Select
    Range("PrintCC1").Select
    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.275590551181102)
        .RightMargin = Application.InchesToPoints(0.275590551181102)
        .TopMargin = Application.InchesToPoints(0.275590551181102)
        .BottomMargin = Application.InchesToPoints(0.15748031496063)
        .HeaderMargin = Application.InchesToPoints(0.236220472440945)
        .FooterMargin = Application.InchesToPoints(0.31496062992126)
        .CenterHorizontally = True
        .CenterVertically = True
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 2
    Application.ScreenUpdating = True
End Sub


Viewing all articles
Browse latest Browse all 50004

Trending Articles