Mandatory field - help with VBA
Posted: Mon Aug 23, 2010 11:02 pm
Hi,
I have a websheet application having 4 columns. 3rd column is change colour and 4th is comment.
When ever we change colour (a dropdown list where we can choose G,R,Y) we have to enter comment y the user changed the colour.
Requirement is we have to make the comment field mandatory if we change the colour. Without entering comment user cannot save or recalculate the sheet.
How can we do it. I searched internet an got a code
Problem is when i use tis code functionality is working but the dbrw rule on the comment and colour field is not working.
Please help.
I have a websheet application having 4 columns. 3rd column is change colour and 4th is comment.
When ever we change colour (a dropdown list where we can choose G,R,Y) we have to enter comment y the user changed the colour.
Requirement is we have to make the comment field mandatory if we change the colour. Without entering comment user cannot save or recalculate the sheet.
How can we do it. I searched internet an got a code
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
Label1:
asd = InputBox("You just changed " & Target.Address & "!. Please insert your comment for doing so!")
If asd = "" Then GoTo Label1
If asd <> "" Then GoTo Label2
Label2:
Cells(Target.Row, Target.Column + 1) = asd
End If
End Sub
Please help.