473,396 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.
Expand|Select|Wrap|Line Numbers
  1. Sub UpdateButton()
  2.   Application.ScreenUpdating = False
  3.   Dim copySheet As Worksheet
  4.   Dim pasteSheet As Worksheet
  5.  
  6.   Set copySheet = Worksheets("Purchase Order")
  7.   Set pasteSheet = Worksheets("PO Log")
  8.  
  9.   copySheet.Range("POnumber").Copy
  10.   pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  11.   Application.CutCopyMode = False
  12.   Application.ScreenUpdating = True
  13.  
  14.   copySheet.Range("OrderSummary").Copy
  15.   pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  16.   Application.CutCopyMode = False
  17.   Application.ScreenUpdating = True
  18.  
  19.   copySheet.Range("POdate").Copy
  20.   pasteSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  21.   Application.CutCopyMode = False
  22.   Application.ScreenUpdating = True
  23.  
  24.   copySheet.Range("RequestedBy").Copy
  25.   pasteSheet.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  26.   Application.CutCopyMode = False
  27.   Application.ScreenUpdating = True
  28.  
  29.   copySheet.Range("Vendor").Copy
  30.   pasteSheet.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  31.   Application.CutCopyMode = False
  32.   Application.ScreenUpdating = True
  33.  
  34.   copySheet.Range("DeliveryDate").Copy
  35.   pasteSheet.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  36.   Application.CutCopyMode = False
  37.   Application.ScreenUpdating = True
  38.  
  39.   copySheet.Range("Cost").Copy
  40.   pasteSheet.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  41.   Application.CutCopyMode = False
  42.   Application.ScreenUpdating = True
  43.  
  44.   Range("='Purchase Order'!$B$2:$N$47").PrintOut
  45.  
  46.   End Sub
  47.  
Nov 4 '19 #1

✓ answered by Barracuda72

For all that are interested.... The solution to my issue was
Expand|Select|Wrap|Line Numbers
  1.  
  2.  If IsEmpty(Range("OrderSummary")) Or IsEmpty(Range("RequestedBy")) Or IsEmpty(Range("POnumber")) Then
  3.  MsgBox "Information is Missing:Requested By, Order Summary, and P.O. Require User Input", vbRetryCancel
  4.  Exit Sub
  5.  End If
That is all...

2 1482
Okay... So I think I have figured part of it out with
Expand|Select|Wrap|Line Numbers
  1. If Cells(4, 3).Value = "" Then
  2. MsgBox "Requested By Requires User Input"
  3.  
  4. Cancel = True
  5. 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.
Expand|Select|Wrap|Line Numbers
  1. Sub UpdateButton()
  2.   Application.ScreenUpdating = False
  3.   Dim copySheet As Worksheet
  4.   Dim pasteSheet As Worksheet
  5.  
  6.   Set copySheet = Worksheets("Purchase Order")
  7.   Set pasteSheet = Worksheets("PO Log")
  8.  
  9.   copySheet.Range("POnumber").Copy
  10.   pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  11.   Application.CutCopyMode = False
  12.   Application.ScreenUpdating = True
  13.  
  14.   copySheet.Range("OrderSummary").Copy
  15.   pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  16.   Application.CutCopyMode = False
  17.   Application.ScreenUpdating = True
  18.  
  19.   copySheet.Range("POdate").Copy
  20.   pasteSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  21.   Application.CutCopyMode = False
  22.   Application.ScreenUpdating = True
  23.  
  24.   copySheet.Range("RequestedBy").Copy
  25.   pasteSheet.Cells(Rows.Count, 4).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  26.   Application.CutCopyMode = False
  27.   Application.ScreenUpdating = True
  28.  
  29.   copySheet.Range("Vendor").Copy
  30.   pasteSheet.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  31.   Application.CutCopyMode = False
  32.   Application.ScreenUpdating = True
  33.  
  34.   copySheet.Range("DeliveryDate").Copy
  35.   pasteSheet.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  36.   Application.CutCopyMode = False
  37.   Application.ScreenUpdating = True
  38.  
  39.   copySheet.Range("Cost").Copy
  40.   pasteSheet.Cells(Rows.Count, 7).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
  41.   Application.CutCopyMode = False
  42.   Application.ScreenUpdating = Tru
  43.  
  44. If Cells(4, 3).Value = "" Then
  45. MsgBox "Requested By Requires User Input"
  46.  
  47. Cancel = True
  48. End If
  49.  
  50. Range("='Purchase Order'!$B$2:$N$47").PrintOut
  51.  
  52.   End Sub
Nov 4 '19 #2
For all that are interested.... The solution to my issue was
Expand|Select|Wrap|Line Numbers
  1.  
  2.  If IsEmpty(Range("OrderSummary")) Or IsEmpty(Range("RequestedBy")) Or IsEmpty(Range("POnumber")) Then
  3.  MsgBox "Information is Missing:Requested By, Order Summary, and P.O. Require User Input", vbRetryCancel
  4.  Exit Sub
  5.  End If
That is all...
Nov 6 '19 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
4
by: J055 | last post by:
Hi I have 2 update buttons in my FormView ('Apply' and 'OK'). I want both buttons to update the data source but the 'OK' button should redirect afterwards. I can see which button is clicked...
0
by: ayneekeaw | last post by:
When I click the update button/link at the Gridview to update the data from drop down list into the SQL. The selected value of drop down list change to default value. How can I fix this problem
0
by: mesut | last post by:
Hi there, I've a question. I would like to create a global update button to update all changed records gridview. e.g. A gridview contains 5 columns an 2 of the columns can be updated by the...
1
by: schuiazza | last post by:
Hi, I am updating a webpage which displays information about electrical networks. The company requires to update gridstation information regarding voltage based on each are i..e south east etc,...
1
by: geeteshss | last post by:
Dear all, actually i spent a whole month on the R&D of datagrid edit ,update,cancel events but recently my guide told me to make it user friendly because no user would like to go on searching rows...
0
by: stimul8d | last post by:
Before i get flamed, this isn't the usual question you see left right and center. I'm dynamically creating usercontrols inside the page_init event and setting the ID's of each control so that the...
3
by: shekharncst | last post by:
Hi I am using GridView in ASPX page <asp:GridView AutoGenerateEditButton ="false" id="siGridView" runat="server" Font-Names="Cordia New" Font-Size="Smaller" ...
0
by: Cad33ee | last post by:
Good Day! I Am using Microsoft Access 2016. I would like to know how can i create a simple update button. I already created add, clear and close. However, I do have a hard time on creating an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.