Message Box to Prompt Input Based on Another Cell

welshraz

New Member
Joined
Apr 29, 2016
Messages
39
Office Version
  1. 365
Platform
  1. Windows
Afternoon,

I want to create a prompt to ensure column O is input with data if the corresponding cell in column F contains the work "Repair". Column F contans dropdown options, and once a user choses one of the three options that contain the work repair, I would like a pop up box to prompt them to input a reason fior the repair in column O.

Any help greaty appreciated!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Right-click on the sheet tab name at the bottom of your screen, select "View Code" and paste this VBA code in the VB Editor box that pops up:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim reason As String

'   Exit if multiple cells updated at once
    If Target.CountLarge > 1 Then Exit Sub
    
'   Run if value updated in column F and is "Repair"
    If Target.Column = 6 And Target.Value = "Repair" Then
'       Prompt for entry into column O
        reason = InputBox("Please enter the reason for the repair")
'       Populate column O
        Target.Offset(0, 9) = reason
    End If
    
End Sub
This should automatically do what you want.
 
Upvote 1
Solution
Hi
takes me awhile to type code these days but solution similar to @Joe4

Place code in your worksheets code page

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Response    As Variant
    If Target.CountLarge > 1 Then Exit Sub
    On Error GoTo exitsub
    If Target.Column = 6 Then
        If Target.Value = "Repair" Then
            Do
                Response = InputBox("Please Enter Reason For Repair", "Reason")
                'cancel pressed
                If StrPtr(Response) = 0 Then Err.Raise 18
            Loop Until Len(Response) > 0
            'post response to Column O
            Application.EnableEvents = False
            Target.Offset(, 9).Value = Response
        End If
    End If
exitsub:
Application.EnableEvents = True
End Sub

Dave
 
Upvote 1
You are welcome.
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,215,153
Messages
6,123,325
Members
449,097
Latest member
gameover8

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