freeisgood
New Member
- Joined
- Jan 18, 2008
- Messages
- 31
Hello,
I am learning VBA, the assignment is to achieve the following:
Column A: Employee/ID
Column B: Review (Validation with the following option: 1)Like it, 2)Don’t Like it 3)See Comment
Column C: Reason (if “Like it” or “Don’t Like it” is chosen “n/a” should be automatically populate in column c and if “See Comment” is chosen then cell in column c should be available for user to enter their comment.)
The workbook will be located in shared drive which is in shared and protected mode. 500 respondents is expected The following code work only if there is no gap/skip “Review”, but if you skip one entry the code would work. I think that I know where is the problem (“If Cells(xRow, 2).Value = "" Then End”, but can’t come with alternative.
Please Help!
Thanks you.
Codes:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim xRow As Integer
xRow = 2
For xRow = 2 To 502
If Cells(xRow, 2).Value = "" Then End
'do nothing
If Cells(xRow, 2).Value = "See Comment" Then
'do nothing
Else
If Cells(xRow, 2).Value <> "" Then Cells(xRow, 3).Value = "n/a"
End If
Next xRow
Application.ScreenUpdating = True
End Sub
I am learning VBA, the assignment is to achieve the following:
Column A: Employee/ID
Column B: Review (Validation with the following option: 1)Like it, 2)Don’t Like it 3)See Comment
Column C: Reason (if “Like it” or “Don’t Like it” is chosen “n/a” should be automatically populate in column c and if “See Comment” is chosen then cell in column c should be available for user to enter their comment.)
The workbook will be located in shared drive which is in shared and protected mode. 500 respondents is expected The following code work only if there is no gap/skip “Review”, but if you skip one entry the code would work. I think that I know where is the problem (“If Cells(xRow, 2).Value = "" Then End”, but can’t come with alternative.
Please Help!
Thanks you.
Codes:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Dim xRow As Integer
xRow = 2
For xRow = 2 To 502
If Cells(xRow, 2).Value = "" Then End
'do nothing
If Cells(xRow, 2).Value = "See Comment" Then
'do nothing
Else
If Cells(xRow, 2).Value <> "" Then Cells(xRow, 3).Value = "n/a"
End If
Next xRow
Application.ScreenUpdating = True
End Sub