Excel Macro to start cursor at a specific field

I am using the following code to tab from F to G. Then it goes down to F then G again and so on and so on. I am just entering data into the F and G field. What i need is when open the cursor automatically starts at F6. Here is my code. Can I add anything to start at F6?

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Column > 7 Then
     Application.EnableEvents = False
     Target.Offset(1, -Target.Column + 6).Select
     Application.EnableEvents = True
End If
End Sub

allenkentAsked:
Who is Participating?
 
Brian GeeCommented:
Both events can co-exist. One just addresses what to perform at Worksheet open, and the other runs your IF statement upon a Worksheet change event.

Private Sub Workbook_Open()
     Range("F6").Select
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
     If Target.Column > 7 Then
          Application.EnableEvents = False
          Target.Offset(1, -Target.Column + 6).Select
          Application.EnableEvents = True
     End If
End Sub

Open in new window

0
 
point_pleasantCommented:
try
Range("F6").Select
0
 
Brian GeeCommented:
I just tested this and it worked for me:

Option Explicit

Private Sub Workbook_Open()
     Range("F6").Select
End Sub

Open in new window

0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
allenkentAuthor Commented:
I tried plugging in and get errors. Here is my code. Do I put the F6 after the word range?

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Column > 7 Then
     Application.EnableEvents = False
     Target.Offset(1, -Target.Column + 6).Select
     Application.EnableEvents = True
End If
End Sub
0
 
Brian GeeCommented:
Using the code I put above (you can exclude the Option Explicit), once you open your Workbook, the cell F6 will be selected. It's using the Open action of the Workbook to trigger the F6 cell selection.
0
 
allenkentAuthor Commented:
What about my code? I need both things to happen. When I put both codes I get an error. I need it to open at F6 and only go from F to G on tabs.
0
 
point_pleasantCommented:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Range("F6").Select
If Target.Column > 7 Then
     Application.EnableEvents = False
     Target.Offset(1, -Target.Column + 6).Select
     Application.EnableEvents = True
End If
End Sub
0
 
allenkentAuthor Commented:
Point Pleasant code does not let me go anywhere except F6. It always stays in F6
Yobri code does not start in F6 but instead it opens in A41 everytime.

0
 
point_pleasantCommented:
not seeing the code beore the sub call


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)


i would suggest you move the

Range("F6").Select


before the call is made to your sub


0
 
Brian GeeCommented:
Could you try closing Excel entirely and then relaunching it? That Workbook_Open sub really should leave no other option but to select cell F6 at open...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.