Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-02-2015, 04:29 PM
macropod's Avatar
macropod macropod is offline Auto fill drops down using VBA code based on selection Windows 7 64bit Auto fill drops down using VBA code based on selection Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,370
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

If you replace the ddOCost & ddWCost dropdowns with text formfields of the same name, your two macros could be reduced to:
Code:
Sub PopulatedCosts()
Dim ddOCost As String, ddWCost As String
With ActiveDocument
  Select Case .FormFields("ddSize").Result
    Case "20kW": ddOCost = "$993.00": ddWCost = "$1,568.00"
    Case "56kW": ddOCost = "$1,471.00": ddWCost = "$2,046.00"
    Case "100kW": ddOCost = "$1,759.00": ddWCost = "$2,334.00"
    Case "125kW": ddOCost = "$2,220.00": ddWCost = "$2,795.00"
    Case "150kW": ddOCost = "$2,322.00": ddWCost = "$2,897.00"
    Case "175kW": ddOCost = "$2,322.00": ddWCost = "$2,897.00"
    Case "200kW": ddOCost = "$2,890.00": ddWCost = "$3,465.00"
    Case "250kW": ddOCost = "$3,561.00": ddWCost = "$4,136.00"
    Case "300kW": ddOCost = "$4,821.00": ddWCost = "$5,396.00"
    Case "350kW": ddOCost = "$5,760.00": ddWCost = "$6,335.00"
    Case "400kW": ddOCost = "$5,510.00": ddWCost = "$6,085.00"
    Case "450kW": ddOCost = "$5,980.00": ddWCost = "$6,555.00"
    Case "500kW": ddOCost = "$7,201.00": ddWCost = "$7,776.00"
    Case "650kW": ddOCost = "$7,817.00": ddWCost = "$8,392.00"
    Case "700kW": ddOCost = "$6,770.00": ddWCost = "$7,345.00"
    Case "750kW": ddOCost = "$10,370.00": ddWCost = "$10,945.00"
    Case "800kW": ddOCost = "$10,656.00": ddWCost = "$11,231.00"
    Case "900kW": ddOCost = "$10,969.00": ddWCost = "$11,544.00"
    Case "1,000kW": ddOCost = "$13,495.00": ddWCost = "$14,070.00"
    Case "1,250kW": ddOCost = "$14,951.00": ddWCost = "$15,526.00"
    Case "1,500kW": ddOCost = "$19,753.00": ddWCost = "$20,328.00"
    Case "2,000kW": ddOCost = "$24,269.00": ddWCost = "$24,844.00"
    Case Else: ddOCost = "": ddWCost = ""
  End Select
  .FormFields("ddOCost").Result = ddOCost
  .FormFields("ddWCost").Result = ddWCost
End With
End Sub
PS: You might want to check whether you have the right costings for the 350kW, 400kW, 650kW & 700kW entries.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 11-03-2015, 06:05 AM
AgilityJS AgilityJS is offline Auto fill drops down using VBA code based on selection Windows 10 Auto fill drops down using VBA code based on selection Office 2013
Novice
Auto fill drops down using VBA code based on selection
 
Join Date: Oct 2015
Location: Charlotte, NC
Posts: 3
AgilityJS is on a distinguished road
Default

Thanks, so much.

This works exactly like i was trying to do.

I'm very new to VBA coding, do you have an suggestions on material or sites I can use to learn more?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto fill drops down using VBA code based on selection Form auto fill based on a different field value. stct Word 31 05-02-2024 04:48 PM
VBA Code to Hide columns based on selection on prior sheet Silver1379 Excel Programming 0 04-15-2015 08:40 AM
text based on Combo box selection rosscortb Word VBA 3 03-16-2015 06:57 PM
Inserting a particular image based on a combobox selection LeonieD PowerPoint 2 06-27-2014 05:39 PM
Auto fill drops down using VBA code based on selection how to populate textbox based on combobox selection in word IvanGeorgiev Word VBA 1 02-21-2013 07:28 PM

Other Forums: Access Forums

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