Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-05-2013, 09:51 AM
Elan05 Elan05 is offline Macro to Skip Calcuation if Field is Blank?! Windows 7 64bit Macro to Skip Calcuation if Field is Blank?! Office 2010 64bit
Novice
Macro to Skip Calcuation if Field is Blank?!
 
Join Date: Mar 2013
Posts: 13
Elan05 is on a distinguished road
Post Macro to Skip Calcuation if Field is Blank?!


Hello,
I have the following macro in my document to calculate a payment amount, based on the times per year the contract is invoiced. My macro is repeated for Year3 - Year5... I wanted to know if there is something that I can add to this so that if any years beyond the Year1 are not filled in (form field left blank) the macro won't try to calculate. Right now, if some of the form fields aren't filled in, I get an error message when I exit the fields that are empty.
Code:
Sub CalcPayable() 
' ' CalcPayable Macro If ActiveDocument.FormFields("Cycle").Result = "Annually" Then ActiveDocument.FormFields("Payable1").Result = ActiveDocument.FormFields("Year1").Result ElseIf ActiveDocument.FormFields("Cycle").Result = "Semiannually" Then ActiveDocument.FormFields("Payable1").Result = ActiveDocument.FormFields("Year1").Result / 2 ElseIf ActiveDocument.FormFields("Cycle").Result = "Quarterly" Then ActiveDocument.FormFields("Payable1").Result = ActiveDocument.FormFields("Year1").Result / 4 ElseIf ActiveDocument.FormFields("Cycle").Result = "Bimonthly" Then ActiveDocument.FormFields("Payable1").Result = ActiveDocument.FormFields("Year1").Result / 6 ElseIf ActiveDocument.FormFields("Cycle").Result = "Monthly" Then ActiveDocument.FormFields("Payable1").Result = ActiveDocument.FormFields("Year1").Result / 12 ElseIf ActiveDocument.FormFields("Cycle").Result = "Triannually" Then ActiveDocument.FormFields("Payable1").Result = ActiveDocument.FormFields("Year1").Result / 3 End If
If ActiveDocument.FormFields("Cycle").Result = "Annually" Then ActiveDocument.FormFields("Payable2").Result = ActiveDocument.FormFields("Year2").Result ElseIf ActiveDocument.FormFields("Cycle").Result = "Semiannually" Then ActiveDocument.FormFields("Payable2").Result = ActiveDocument.FormFields("Year2").Result / 2 ElseIf ActiveDocument.FormFields("Cycle").Result = "Quarterly" Then ActiveDocument.FormFields("Payable2").Result = ActiveDocument.FormFields("Year2").Result / 4 ElseIf ActiveDocument.FormFields("Cycle").Result = "Bimonthly" Then ActiveDocument.FormFields("Payable2").Result = ActiveDocument.FormFields("Year2").Result / 6 ElseIf ActiveDocument.FormFields("Cycle").Result = "Monthly" Then ActiveDocument.FormFields("Payable2").Result = ActiveDocument.FormFields("Year2").Result / 12 ElseIf ActiveDocument.FormFields("Cycle").Result = "Triannually" Then ActiveDocument.FormFields("Payable2").Result = ActiveDocument.FormFields("Year2").Result / 3 End If End Sub

Last edited by macropod; 04-05-2013 at 02:13 PM. Reason: Added code tags & formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Skip Calcuation if Field is Blank?! Macro to remove blank column netchie Word VBA 4 03-14-2013 02:22 PM
Email macro to read range for .To field MattMurdock Excel Programming 2 08-07-2012 06:46 AM
Macro to Skip Calcuation if Field is Blank?! Assign macro but hide the button/field trlear Word VBA 5 02-23-2012 04:35 PM
Macro to Skip Calcuation if Field is Blank?! Form Fields - Create blank form text field with if statement? LAssist2011 Word 5 12-14-2011 03:02 PM
Macro to Skip Calcuation if Field is Blank?! How to turn all blank lines into non-blank for legal forms sieler Word 3 04-12-2009 01:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft