I received this question a little while ago and that the guys at has a barcode
scanner that's going directly into his excel and he wants to have the date and
time next to the barcode that is that it's scanned so what I've done is I
figured out how to do this so what we're going to do is we're going
to start with a new sheet here and so in the a column I'm going to put a place
for the barcode scan to go and then in the next cell I'm going to put the date
and time okay so let's just make this look like a header or something and so
I'm going to gray the background I'm gonna bold it so now let's go to the
Developer tab visual basic and then what we're going to do is we are going to
double click on sheet1 okay so now we want this just to work on sheet 1 right
and so what we're gonna do is we're going to where it says general here
we're going to drop that down and we're gonna say worksheet and then on select
some change we're going to change that to just say change ok so this is where
we're going to write our macro and so we're going to define a variable and so
I'm going to say dim X as integer
so I filled in all the rest of the code so that you didn't have to watch me
tight and so I'm saying 4x equals 2 because we have heading row 0 in Row 1
to 100 now I have no idea how many products these people would be scanning
in in a day maybe you want to make this to be a thousand or ten thousand or
whatever but I'm just using it for a hundred for right now so if sells X 1 X
being the the row and 1 being the column so that's the a column value does not
equals nothing and sells X comma 2 value equals nothing then sells X 2 so we want
the value and we want it to be date and if you put so we need to add date to
time and what we're going to do is put a couple spaces between date and time so
that they're not on top of each other so you literally write the word date you
put an ampersand you put quotation marks and you put a space in between there and
then there ampersand and the time and then we're going to format the date so
we're going back to the B column here and then you go number format and so
we're going month day and year and then we want the time as well so we go in
hours minutes and then we're gonna have we're gonna have it indicate either a.m.
or p.m. so then we're going to end the F here and then we're gonna go next for
the 4 and then what we're gonna do is range B B which is the date and time
he's going to autofit so that we don't have it all rolling over into the next
so let's try this code out so I don't have a barcode scanner but I know that
barcode the numbers you get Ramona got barcode scanner or like eight or nine
digits long so I'm gonna just
try it out and there you go you have the the date and the time
entered in automatically now you entering another one here and you go and
there you go it it automatically enters it as you as you enter anything in here
it automatically enters the date and time in the corresponding column beside
it so that's how you enter the time for entering your your barcode scans please
subscribe