+ Reply to Thread
Results 1 to 2 of 2

If statement with conditions on some....

Hybrid View

albertc If statement with conditions... 05-14-2012, 05:38 AM
StevenM Re: If statement with... 05-14-2012, 06:01 AM
  1. #1
    Registered User
    Join Date
    11-07-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Question If statement with conditions on some....

    Hello everybody.

    I need to achieve the following;

    When executing macro Check_Info I want to check if cell AR1 is missing and return info msg Customer Name is missing, then stop running macro, I AR1 has data then check if cell W17 is empty, if so return info msg Delivery date is missing. Then a condition statement would you like to carry on wihout a delivery date? If yes then continue running macro if not then stop macro (I believe End Sub???? If carry on then check next cell AW17 if empty then info msg Processed By field is empy, and stop running macro.

    What am I doing wrong here?

    I have managed to have msg error for Customer name empty but this is only showing when there is data in the cell?

    Any help appreciated.

    Regards,
    Albert

    Sub Check_Info()
        
        If Range("AR1").Value <> Empty Then
        
        MsgBox "Customer Name is missing."
        
        Exit Sub
        
        End If
        
        
        
        If Range("AY73").Value > 0 Then
    
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
            IgnorePrintAreas:=False
            
        Sheets("Saved Invoices").Unprotect Password:="15951"
        
        Dim Data(1 To 4) As Variant
        Dim DstRng As Range
        Dim RngEnd As Range
        
            Set DstRng = Worksheets("Saved Invoices").Range("A2:D2")
            Set RngEnd = DstRng.Parent.Cells(Rows.Count, DstRng.Column).End(xlUp)
            Set DstRng = IIf(RngEnd.Row < DstRng.Row, DstRng, RngEnd.Offset(1, 0).Resize(1, 4))
            
            With Worksheets("Invoice")
                Data(1) = .Range("L17")  'Invoice number
                Data(2) = .Range("A17")  'Date
                Data(3) = .Range("AR1")  'Customer
                Data(4) = .Range("AY73") 'Amount
            End With
            
            DstRng = Data
            
            Sheets("Saved Invoices").Protect Password:="15951"
            
            ActiveWindow.Zoom = 80
        Range( _
            "AR1:BG1,W17:AI17,AW17:BG17,I20:AD67,AI20:AK67,AU20:AX67,AY20:BA67,G70:T70,AA70:AK70,G71:AK71,G74:P74,G75:P75,Z74:AK74,Z75:AK75" _
            ).Select
        Range("Z75").Activate
        Selection.ClearContents
        Range("AR1:BG1").Select
        ActiveWindow.Zoom = 150
        
        Sheets("Invoice").Unprotect Password:="15951"
    
        With Range("L17")
        .NumberFormat = "00000"
        .Value = .Value + 1
        End With
    
        Sheets("Invoice").Protect Password:="15951"
    
        ActiveWorkbook.Save
                
        
        Else
        MsgBox "ATENTION!!! Invoice cannot be printed if total is £00.0."
        End If
           
    End Sub

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: If statement with conditions on some....

    Instead of:

    If Range("AR1").Value <> Empty Then
    How about:

    If IsEmpty(Range("AR1")) Then

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1