Show message box when select drop down list

trivedi

New Member
Joined
Nov 23, 2021
Messages
15
Hi,

I have a drop down list which has y1,y2 and y3 - what i want to do is if I select year 1 message box says you've selected y1 and the same goes for y2 and y3.

I am new to Macros, please help
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Ok I leave it to you to set the message box to what you want it to say for each selection in the the drop down list. I have added the code to each selection to delete 'I2'.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'
    If Not Intersect(Target, Range("C1")) Is Nothing And Target.Cells.Count = 1 Then
        Select Case Target
            Case Is = "y1"
                MsgBox "Please select Y1" & "(Same year)" & " " & "in CONVERTER TAB Cell H2 and delete values" & " " & "(if any) from Cell I2" & " " & "(Import)"
                Sheets("Converter").Range("I2").ClearContents
            Case Is = "y2"
                MsgBox "Please select Y2" & "(Same year)" & " " & "in CONVERTER TAB Cell H2 and delete values" & " " & "(if any) from Cell I2" & " " & "(Import)"
                Sheets("Converter").Range("I2").ClearContents
            Case Is = "y3"
                MsgBox "Please select Y3" & "(Same year)" & " " & "in CONVERTER TAB Cell H2 and delete values" & " " & "(if any) from Cell I2" & " " & "(Import)"
                Sheets("Converter").Range("I2").ClearContents
        End Select
    End If
End Sub

Make sure the 'Converter' sheet name is spelled correctly in the code.

Lemme know how that works.
 
Upvote 0
Ok I leave it to you to set the message box to what you want it to say for each selection in the the drop down list. I have added the code to each selection to delete 'I2'.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'
    If Not Intersect(Target, Range("C1")) Is Nothing And Target.Cells.Count = 1 Then
        Select Case Target
            Case Is = "y1"
                MsgBox "Please select Y1" & "(Same year)" & " " & "in CONVERTER TAB Cell H2 and delete values" & " " & "(if any) from Cell I2" & " " & "(Import)"
                Sheets("Converter").Range("I2").ClearContents
            Case Is = "y2"
                MsgBox "Please select Y2" & "(Same year)" & " " & "in CONVERTER TAB Cell H2 and delete values" & " " & "(if any) from Cell I2" & " " & "(Import)"
                Sheets("Converter").Range("I2").ClearContents
            Case Is = "y3"
                MsgBox "Please select Y3" & "(Same year)" & " " & "in CONVERTER TAB Cell H2 and delete values" & " " & "(if any) from Cell I2" & " " & "(Import)"
                Sheets("Converter").Range("I2").ClearContents
        End Select
    End If
End Sub

Make sure the 'Converter' sheet name is spelled correctly in the code.

Lemme know how that works.
works perfectly fine....thank you so much for the support :)
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

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