VBA or Macro code required

adityaj252

New Member
Joined
May 14, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I have a business requirement where there are total of 3 columns A, B and C. Column A is a dropdown field with let user choose one value from dropdown values (total of 5). Now, if user selects any specific value out of these 5, he/she should get a message popup that column B becomes mandatory corresponding to that A value. In case, if user selects some other value in A column, C column should become mandatory. So I want B and C column to become mandatory only for a specific value of column A but not for all.

Your prompt response would be greatly appreciated.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Welcome to the MrExcel Message Board!

Note: You initially posted your question to the wrong section (Products forum) and it has been moved here by a Forum Moderator. Please send your future Excel-related questions to this forum - the Excel Questions forum.

Regarding your question. It is possible to check the value of the cell on column A when it is changed and popup a message accordingly, however, I hope you understand it is only for informing the user, not actually forcing them to enter something to column B or C.

Please go to VBE (Alt+F11), double-click on the worksheet class module (Sheet1?) in the VBA Project (Ctrl+R) window, and copy & paste the following code into that class module:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    ' Column = 1 means it is Column A
    If Target.Column = 1 Then
        ' Used 1,2,3,4,5 as the list for the dropdown values
        Select Case Target.Value
            Case 1, 3, 4
                MsgBox "Column B is mandatory"
            Case 2, 5
                MsgBox "Column C is mandatory"
        End Select
    End If
End Sub

The sample code contains 1,2,3,4,5 values in the dropdown list and sets the specific values as shown in the Select Case to decide which column to be mandatory. You need to change those by using your values and criteria.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,861
Members
449,052
Latest member
Fuddy_Duddy

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