When a drop down list is changed, VBA code to insert a formula into other cells (which are also a drop lists)

Steve1208

New Member
Joined
Nov 10, 2017
Messages
28
I have been trying to get the VBA to enter a specific formula into another cell (which are also drop down lists) when another drop down list is changed. Please see below for clarity:


Cell C2 - When this drop list cell is changed

Cell B14 - I would like this drop list to have the following formula automatically inserted:
="Contract Controls:"&" "&INDEX(Contract!D95:XFD95,MATCH('CHECKLIST 2'!C2,Contract!D3:XFD3,0))

Cell A14 - I would also like this drop list to have the following formula automatically inserted:
="Contract:"&" "&INDEX(Contract!D4:XFD4,MATCH('CHECKLIST 2'!C2,Contract!D3:XFD3,0))

Thank you in advance for any advice

Best Regards
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi Steve,

Here's some code for you to try. Copy it into the Sheet Code Module of the sheet that has the 3 dropdown cells. To get to that module, right-click the tab of that sheet then pick: View Code

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim sErrMsg As String
  
 On Error GoTo ErrProc
 Application.EnableCancelKey = xlErrorHandler
 Application.EnableEvents = False
 
 If Target.Address <> "$C$2" Then GoTo ExitProc
 
 Me.Range("B14").Formula = _
   "=""Contract Controls:""&"" ""&INDEX(Contract!D95:XFD95,MATCH('CHECKLIST 2'!C2,Contract!D3:XFD3,0))"

 Me.Range("A14").Formula = _
   "=""Contract:""&"" ""&INDEX(Contract!D4:XFD4,MATCH('CHECKLIST 2'!C2,Contract!D3:XFD3,0))"


ExitProc:
 On Error Resume Next
 Application.EnableEvents = True
 If Len(sErrMsg) Then MsgBox sErrMsg
 Exit Sub

ErrProc:
 sErrMsg = Err.Number & ": " & Err.Description
 Resume ExitProc
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top