so now to make this a little more interesting let's take this code that i wrote here and
convert it to a data entry script and what i mean by that i'll go to a different sheet
here i'm gonna call this one form
and here i'm gonna basically add a couple of things i'm gonna enter amount
quantity and that's pretty much it so basically i'll add some amount here and then some quantity
here and what i want i want the button here that when i click on this it will add this amounts and
quantities to this data tab over here in this columns let's actually add a row here and call
this like amount this one quantity and for this one we'll do a timestamp so it will tell us when
this happened instead of doing line number in order to do this
i'm going to first have to grab this information from this particular cells so for that reason
i need access to this worksheet called form so i'm going to go ahead and create a variable here
now we need to give it a different name
from this form sheet we need to get our information from these two cells there are two
options we have here we can get this as an array both values at the same time but i'm just going
to get each value separately for this example so what i'll do here i'll just access both of those
values so i'll do const amount and for that we'll take that form sheet we'll get the range
and here i'll just keep it simple i'll just do a2 and i'll do dot get value to get the value
of that cell because it's a single cell it's value not values i'm going to copy this line
and for this one we'll do qty for quantity and this will be b2 cell we'll grab the value
from that cell for this so now this amount would be the number here qty would be the number
here next let's try to get our current time so i'll do const current time
and for this we can use javascript date object to create our current date and time let's actually
call it current date time instead of just current time okay so now we should have this
three variables amount qty and current date time that's pretty much what we need to add
here we're adding that to this data tab we already have that we need to find our
range so it's gonna find this used range and after that we're gonna find the last row
here and then we're going to find the next row range which is going to be this line
and finally we're going to put those values here comma separated in this particular order so we
need timestamp to be the first one so here what i'll do i'll use that current datetime
comma then the second one is going to be amount and then finally we're gonna have qty
for quantity right there now you can see that it's not happy about this current date time
because this is actually a date object and it says that we cannot make it a string number or boolean
so we need to convert it in some way to something more readable and we can do it either here or we
can do it directly here i'll just do it directly here so i'm gonna do dot so these are methods
on this date that we have available so as you can see we can set some things we can get some things
we can basically do to date string or to this one i don't know i'm gonna just pick one
let's do this one for now we'll probably get more fancy excel like dates as we go forward for now
i'm gonna do this that's good enough and save this so now it's going to be string date and this will
stop complaining about it so at this point if i remember i got this two things 45 and the seven
so if i go ahead and run this so let's go and check out what happened in our data tab
so as you can see we got our date and time entered here in this weird format and like
i said i'm not going to worry about formatting in this particular video but you can see how we got
45 and seven in these lines now at this point i can go here and update these two let's say
12 and three and then rerun this and now it should enter those two things in our data tab see 12 3 in
our next line just like that it might be worth to just clear these cells after we enter that data so
basically what we can do after we set these values in our next line we can then clear those values
now since i'm going to be pointing to that same a2 cell to clear it later on i'm just gonna
move that range to its own line so i'll just grab this much and do const amount range equals that
let's get rid of this and then i'll copy this much and do const qty range equals this and
then here instead of doing this i'll just use this amount range variable which refers to this which
is the same as this so we'll do amount range and that's same thing we'll do here with our qty range
and so far it will just make our script work as it did but now i can later use
this amount range in qty range in my code down here so i can do amount range dot clear
and then qty range dot clear so that way we'll clear what's in the cell after we add it to our
data tab so before i go ahead and run this the last thing we can do we can add a button here
so i can go back to my previous screen over here this is that particular
script the name for it is script three we could rename that to something better
and then over here we have these three
little dots and as you can see we have this option to add button
so i'm going to go ahead and do that and you can see it adds this button it took a second so now i
should be able to close this and this is my button over here so let's just enter some number and some
number here too i'm gonna click add data so that's gonna start running the script as you can see
so once the data is in my data tab see it's clearing this so if i go to my data tab
here you can see that's in this line now and then i can keep using this
the same way as i did before
so it's gonna add
right there so that should do it
thanks for watching please subscribe and i'll see the next video