PDA

View Full Version : Skip Cell VBA Help Change Code



Alphacsulb
03-20-2008, 02:51 PM
This is the code I have:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Cells(1, Target.Column) <> "X" Then Target.Offset(0, 1).Select
End Sub

This code will control all rows starting with 2 all the way down.

However, I want this code only to apply to row 2.

I need a code like the one above but I want it to work with my table.

My table is below:
http://i88.photobucket.com/albums/k193/Rgarcia9/253c15de.jpg

:dunno Im lost.

Help!!!

Julia

Simon Lloyd
03-20-2008, 03:09 PM
Julia please supply your table in excel format here it will be easier, you can upload an excel file directly here, as for your code above it only selects the cell in the next column if the curren column row 1 displays X so doesn't really "control" all columns starting with 2! it must be some other code that you have.

Bob Phillips
03-20-2008, 03:11 PM
Your description dosn't tally with what the picture says, but here is a start



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row = 2 Then
If Cells(1, Target.Column) <> "X" Then Target.Offset(0, 1).Select
End If
End Sub

chat163
03-21-2008, 01:51 AM
Based your table you can test below code:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If (Target.Count = 1) And (Target.Row = 6 Or Target.Row = 7 Or Target.Row = 10 Or Target.Row = 11 Or Target.Row = 14 Or Target.Row = 15) Then
If Cells(Target.Row, Target.Column) <> "X" Then Target.Offset(0, 1).Select
End If
End Sub

Edited by Simon Lloyd
chat163, thanks for your response please remember to put code tags around your code by highlighting it then clicking the VBA (green and white) button.