If "yes" then move to next cell, "no" then move to cell in next row

CWelfley01

New Member
Joined
Oct 25, 2017
Messages
11
IF "YES" THEN MOVE TO NEXT CELL, "NO" THEN MOVE TO CELL IN NEXT ROW

Title says it all. I want to have a cell in the middle of my row that will decide if i move to the next cell in the same row or go back to the start of the next row. Any help is appreciated!! I have never even accessed VBA so please keep me in the function area.
Thanks in advance!!!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
In what row and column is your Yes/No cell?
 
Upvote 0
I'm not sure what you mean by
I need it to be fluid. 8 cells into my row
I'm basing the macro on the Yes/No always being in any row in column L. Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter Yes or No in any cell in column L and press the RETURN key.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("L:L")) Is Nothing Then Exit Sub
    If Target = "Yes" Then
        Target.Offset(0, 1).Select
    ElseIf Target = "No" Then
        Cells(Target.Row + 1, 1).Select
    End If
End Sub
 
Last edited:
Upvote 0
IN your original post you said
go back to the start of the next row
The next row starts in Column A so that is the way I wrote the macro. If you want to go to the next row in column D then use this version:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("L:L")) Is Nothing Then Exit Sub
    If Target = "Yes" Then
        Target.Offset(0, 1).Select
    ElseIf Target = "No" Then
        Cells(Target.Row + 1, 4).Select
    End If
End Sub
 
Upvote 0
First make sure that you placed the macro in the worksheet code module as I described in Post #5 . Secondly, column L must be unlocked. I assume that you mean that the sheet is protected when you say
I have the page locked
This version will unprotect the sheet, perform its task and then protect the sheet again.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("L:L")) Is Nothing Then Exit Sub
    ActiveSheet.Unprotect
    If Target = "Yes" Then
        Target.Offset(0, 1).Select
    ElseIf Target = "No" Then
        Cells(Target.Row + 1, 4).Select
    End If
    ActiveSheet.Protect
End Sub
I'm assuming you didn't use a password to protect the sheet.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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