Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-19-2020, 02:13 PM
macropod's Avatar
macropod macropod is offline Calculating tax rate per province in VB Windows 7 64bit Calculating tax rate per province in VB Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I'm not sure that formfield dropdowns will work in this case, as they only accept a maximum of 25 entries and there are more than twice that US States.

As for the tax calculation, with formfields no VBA code is required - it can all be done with field coding. Such a field might be coded along the lines of:
{={IF{REF ddCountr}= "CA" {IF{REF ddRegion}= "ON" 1.13 1.05} 0}*{Half_Fees} \# $,0.00}

Regardless, given the limitation of 25 for formfield dropdown entries, you should instead consider the use of content control dropdowns, for which all your US States can be added. In that case, the VBA code might look like:
Code:
Dim Admin As Single, Tax As Single
With ActiveDocument
  If .SelectContentControlsByTitle("Country")(1) = "US" Then
    Tax = 0
  Else
    If .SelectContentControlsByTitle("Region")(1) = "ON" Then
      Tax = 1.13
    Else
      Tax = 1.05
    End If
  End If
  Admin = .SelectContentControlsByTitle("Admin")(1).Range.Text
  With .SelectContentControlsByTitle("Tax")(1)
    .LockContents = False
    .Range.Text = Format(Tax * Admin, "#,##0.00")
    .LockContents = True
  End With
End With
Note: You shouldn't use content controls and formfields in the same document, as they weren't designed to be used that way and trying to do so can cause problems.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
drop down, formula, formulas drop downs



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating the duration of a task based on work rate Rida Project 0 04-26-2018 03:55 AM
Calculating tax rate per province in VB Average Billing Rate tbrozovich Project 2 08-18-2015 04:00 PM
Calculating tax rate per province in VB Total Hours * hourly rate medavidcook Excel 7 06-04-2015 09:29 AM
Calculating tax rate per province in VB Cost Rate Table Macro Help JohnTurner Project 1 01-27-2014 07:53 AM
Help: Very low response-rate! Jeff10 Office 6 12-17-2013 10:44 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:11 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