Macro assigned to an update button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Barracuda72
    New Member
    • Nov 2019
    • 3

    Macro assigned to an update button

    So.... I have an UpdateButton Macro assigned to my P.O. Generator, and want it to stop and ensure all fields are filled out prior to update.
    Code:
    Sub UpdateButton()
      Application.ScreenUpdating = False
      Dim copySheet As Worksheet
      Dim pasteSheet As Worksheet
    
      Set copySheet = Worksheets("Purchase Order")
      Set pasteSheet = Worksheets("PO Log")
    
      copySheet.Range("POnumber").Copy
      pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("OrderSummary").Copy
      pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("POdate").Copy
      pasteSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("RequestedBy").Copy
      pasteSheet.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("Vendor").Copy
      pasteSheet.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("DeliveryDate").Copy
      pasteSheet.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("Cost").Copy
      pasteSheet.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      Range("='Purchase Order'!$B$2:$N$47").PrintOut
      
      End Sub
  • Barracuda72
    New Member
    • Nov 2019
    • 3

    #2
    Okay... So I think I have figured part of it out with
    Code:
    If Cells(4, 3).Value = "" Then
    MsgBox "Requested By Requires User Input"
    
    Cancel = True
    End If
    But I would like this add-on to stop the updating process as well... HELP!!
    Here's entire code with new MsgBox code.
    Code:
    Sub UpdateButton()
      Application.ScreenUpdating = False
      Dim copySheet As Worksheet
      Dim pasteSheet As Worksheet
    
      Set copySheet = Worksheets("Purchase Order")
      Set pasteSheet = Worksheets("PO Log")
    
      copySheet.Range("POnumber").Copy
      pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("OrderSummary").Copy
      pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("POdate").Copy
      pasteSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("RequestedBy").Copy
      pasteSheet.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("Vendor").Copy
      pasteSheet.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("DeliveryDate").Copy
      pasteSheet.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = True
      
      copySheet.Range("Cost").Copy
      pasteSheet.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Application.CutCopyMode = False
      Application.ScreenUpdating = Tru
    
    If Cells(4, 3).Value = "" Then
    MsgBox "Requested By Requires User Input"
    
    Cancel = True
    End If
    
    Range("='Purchase Order'!$B$2:$N$47").PrintOut
      
      End Sub
    Last edited by Barracuda72; Nov 4 '19, 06:31 PM. Reason: Add the macro code

    Comment

    • Barracuda72
      New Member
      • Nov 2019
      • 3

      #3
      For all that are interested.... The solution to my issue was
      Code:
        
       If IsEmpty(Range("OrderSummary")) Or IsEmpty(Range("RequestedBy")) Or IsEmpty(Range("POnumber")) Then
       MsgBox "Information is Missing:Requested By, Order Summary, and P.O. Require User Input", vbRetryCancel
       Exit Sub
       End If
      That is all...

      Comment

      Working...