ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA (https://www.excelbanter.com/excel-programming/333115-vba.html)

olen

VBA
 
i've some questions in A1-A5, then someone must be answer all the question
weither Yes Or No (B1-B5), But if the answer is Yes, that people must explain
why the answer were Yes in (c1-c5). If they choose Yes, they need/must to
fill in column C1 and can't jump to other question.

Kurt[_7_]

VBA
 
Might be better to do in Access, but how about a userform that just keeps
coming back if the proper fields aren't filled out? You could throw a msgbox
in between to warn users that they need to provide a reason for all "yes"
answers.

....kurt

"olen" wrote in message
...
i've some questions in A1-A5, then someone must be answer all the question
weither Yes Or No (B1-B5), But if the answer is Yes, that people must
explain
why the answer were Yes in (c1-c5). If they choose Yes, they need/must to
fill in column C1 and can't jump to other question.




Bob Phillips[_7_]

VBA
 
Bit crude but it works

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("B1:B5")) Is Nothing Then
With Target
.Offset(0, 1).Activate
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cell As Range
Dim stemp As String

For Each cell In Me.Range("B1:B5")
If cell.Value = "Yes" And cell.Offset(0, 1).Value = "" And _
Target.Address < cell.Offset(0, 1).Address Then
stemp = stemp & cell.Address & vbNewLine
End If
Next cell
If stemp < "" Then
MsgBox "You must give reasons for Yes in : " & vbNewLine & _
stemp
End If
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--
HTH

Bob Phillips

"olen" wrote in message
...
i've some questions in A1-A5, then someone must be answer all the question
weither Yes Or No (B1-B5), But if the answer is Yes, that people must

explain
why the answer were Yes in (c1-c5). If they choose Yes, they need/must to
fill in column C1 and can't jump to other question.





All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com