Moving cursor to next column

amiller6229

New Member
Joined
Mar 6, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I am new to all this and learning as I go. I am a school nurse and developing a new check in system for when students come to see me. Students will be assigned a QR text code of their name on an index card and that will be their nurse pass. When they come to my office, they scan their card and it enters their name with the date and time they came into my office. I have a table set up that has columns for name, date and then columns for why they came and what I did for them. I currently have it set up to when they scan their QR code, their name is entered into column A and the date goes into Column B. I need for the cursor to jump to column C so I can continue to scan or type why they came in. This is the code I currently have that enters the date automatically after their code is scanned. What can I add to this to make the cursor move to Column C automatically?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Integer
For x = 2 To 100
If Cells(x, 1).Value <> "" And Cells(x, 2).Value = "" Then Cells(x, 2).Value = Date & " " & Time
Cells(x, 2).NumberFormat = "m/d/yy h:mm am/pm"


Next
Range("B:B").EntireColumn.AutoFit


End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I am new to all this and learning as I go. I am a school nurse and developing a new check in system for when students come to see me. Students will be assigned a QR text code of their name on an index card and that will be their nurse pass. When they come to my office, they scan their card and it enters their name with the date and time they came into my office. I have a table set up that has columns for name, date and then columns for why they came and what I did for them. I currently have it set up to when they scan their QR code, their name is entered into column A and the date goes into Column B. I need for the cursor to jump to column C so I can continue to scan or type why they came in. This is the code I currently have that enters the date automatically after their code is scanned. What can I add to this to make the cursor move to Column C automatically?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x As Integer
For x = 2 To 100
If Cells(x, 1).Value <> "" And Cells(x, 2).Value = "" Then Cells(x, 2).Value = Date & " " & Time
Cells(x, 2).NumberFormat = "m/d/yy h:mm am/pm"


Next
Range("B:B").EntireColumn.AutoFit


End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub
I also added this code from another answered question, but it moves the cursor back to Column A and the next row down. I need it to move one column over in the next row.

Thank you!
 
Upvote 0
Please try this. I created named ranges for the A and C Columns called QRCodeCol and ReasonCol

Book5
ABC
1QRCodeDate/TimeReason
214473/6/2024 13:14To visit
3
Sheet2




VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  
  If Target.Count > 1 Then Exit Sub
  
  
  If Not Intersect(Range("QRCodeCol"), Target) Is Nothing Then
    Application.EnableEvents = False
    Target.Offset(0, 1).Value = Now()
    Target.Offset(0, 2).Select
    Application.EnableEvents = True
  End If
  
  If Not Intersect(Range("ReasonCol"), Target) Is Nothing Then
    Application.EnableEvents = False
    Target.Offset(1, -2).Select
    Application.EnableEvents = True
  End If
  

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,872
Messages
6,181,501
Members
453,047
Latest member
charlie_odd

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