place cursor in cell next to cell that macro just entered the date into after matching a value

RoxanneF

New Member
Joined
Nov 22, 2017
Messages
3
I am trying to write VBA code to match a value/barcode, enter a date/timestamp then move the cursor to the cell to the right of the timestamp. I have the match and time stamp working but cannot figure out how to have the cursor move to the cell to the right of the time stamp (so in a long list I would like to match a value in B, enter a time stamp in C and then move the cursor right to then allow me to enter a weight for the object with that specific barcode). Often I have long lists to match so once the barcode is matched, I would like the screen to scroll to where the timestamp is entered so I can enter the weight in the next cell in column D. Here is the code I have thus far:
Code:
Private Sub CommandButton1_Click()
      Dim code As Variant
    Dim matchedCell As Range
    
    code = InputBox("Please scan a barcode and hit enter if you need to")
    Set matchedCell = Range("B2:B1000").Find(what:=code, LookIn:=xlValues, lookat:=xlWhole, MatchCase:=True)
    If Not matchedCell Is Nothing Then matchedCell.Offset(0, 1).Value = Now
    
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hello,

normally a barcode-reader writes in a cell comparable to the keyboard. If so, a "change_event" could be the choice.

For your question, maybe this helps:

matchedCell.offset(,2).select

regards
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,629
Members
449,241
Latest member
NoniJ

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