Keeping Date and Data in the same Row on a worksheet Using Vba

  • Is There a Way to keep the same Date and Data in the same row on a worksheet with this code below?. I am trying to update a Hourly Count Sheet and the end users of the form need to close the program and re-enter the data for the next hour. on a daily bases. Is this possible?. Thank You. I have included The Module in this code.

  • The Following is an image one using the VBA code provided. The second image is what is needed.

    this was inputted into the worksheet directly or manually might be a better word to use. As you can see in both images every Column has a Header with the times for every lot , Military time is used, starting with 0000ABC to 0000LotF this is repeated every hour. The next hour of course would be 0100ABC to 0100LotF and so on until column EO that is the last column on the worksheet, starting at 2300ABC to 2300LotF, that ends the counting process until the next day.

  • Attach a workbook, not a picture of it, please.

    Ali :)


    Enthusiastic self-taught user of MS Excel who's always learning!
    If anyone has helped you towards solving a problem, then you can thank them by clicking on the like icon bottom right.

    :!:Forum Rules

  • You say "starting with 0000ABC to 0000LotF "


    Your worksheet headers have a pattern of:


    0000ABC 0000ConRac 0000P4 0000P6 0000LotF 0000Valet (LotF and Valet ARE NOT positioned as described)


    But your submit code is filling the worksheet in the order:


    0000ABC 0000ConRac 0000P4 0000P6 0000Valet 0000LotF (LotF and Valet ARE positioned as described)


    Which is correct?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Assuming that the order in your code is correct and the Worksheet Headers incorrect then try this code for your Submit Procedure (after correcting the Headers)

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

    Edited 9 times, last by KjBox ().

  • Have you tried the code I supplied in Post #7? What about the issue with your Header Row I asked about in Post #6?


    To attach a workbook click "Attachments" at the bottom left of the Reply box (where you type a reply). Click the "Upload" button that appears, a pop-up window will appear, browse to and double click (or select it and click "Open"), the file that you want to upload. The file will then be attached to your reply.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • No, I have not tried it yet I work the graveyard shift from 10 pm to 6 am so not yet as soon as I get some time I will try it and let you I have seen it. Thank you for the instruction on how to upload the workbook. I am doing it from a computer at work and it's telling me the file is too big. So I will Try it on my Computer at home.



    Book 3.xlsm

  • The file must be more than 3 MB, it is this site that rejects it (maximum upload file size accepted is 3 MB) not your PC.


    You do not need to upload the whole file just the Database sheet (with header row only), the userform and all code in modules should suffice.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

    Edited 3 times, last by KjBox ().

  • I just tried the code you gave me Thank You for that. It dose work but it repeats the date 24 times and it is starting in Row # 3 and not row #2. It's also going down the column, I need it to go from Left to Right as if you were reading a book with. Thank You again for your time. :thumbup: :)

  • Try

    Assumes that the new data will be saved after all 6 text boxes for the current hour have been completed.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • The New Code you sent me Thank You again. I really appreciate you for trying to help me with this. :thumbup: :)

    Maybe what i am asking for is not possible. when the Form unloads and then it's reloaded to enter a new set of numbers they are showing up in a different row and it all needs to be on the same row for the date in question. I 'am attaching the Database sheet with the code you provided so you can see what i am talking about. :thumbup: :thumbup: :)


    Book 3.xlsm

  • What you want is certainly possible, issue is trying to establish just what you need :)


    Can you confirm that you need a result as shown in the second image in Post 4?


    Can you tell me just how the file is used? In other words is it opened every hour and data for the hour previous hour entered, or is data entered for more than one hour entered each time the file is opened, or something else?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • I guess, with the workbook in your last attachment, you opened the user form entered data for Time 0000, then saved. Then opened the user form again and entered data for Time 0400 but also re-entered the data for Time 0000 and saved again.


    If you had just entered the data for Time 0400 and Saved all would have been good.


    Why did you re-entered the data for Time 0000 when data for Time 0000 had already been saved?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • The way the from should work Numbers are entered every hour into the from by different users.

    Example one user will enter numbers at 12am, (0000Hours) and then log off. The next user will enter his or her numbers at 1am, (0100hours) then him or her will also log off. We also have some user that like to enter there numbers in the wrong time slot which is fine as long as they are the correct numbers. The Process of entering number and logging off is a 24 hours process that ends at 11pm(2300hours) daily. Here is the trick it all must appear on the worksheet under one Date and in one Row. at the end of lets say a week, all user numbers entered should have the date that they were enter by row, Even if the user picked the wrong time slot. All numbers enter are done on the From. I am the only on with access to the worksheet. :) :thumbup: .

  • Sorry I am more confused than before.

    it all must appear on the worksheet under one Date and in one Row

    Yet the second image in post 4, which you said was your desired result, shows the 6 entries for each hour on separate rows.

    We also have some user that like to enter there numbers in the wrong time slot which is fine as long as they are the correct numbers.

    So somebody enters data for 0200 hours which is correct, then the 0800 hours user also enters his data in the 0200 time slot. That would overwrite the correct 0200 data and leave 0800 empty, and that is "fine"?


    You still have not said if the data is saved every hour or if the Save button on the userform is clicked only after the 2300 data has been entered and all times have data.


    You have not answered what I asked in Post 17 or said if that was what you did.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • the Save button is click only, all the other buttons on then form are for my use only they can not be access by the users. As for post #17, the repeated numbers i see what you are talking about, that was my fault. the form clears evetime it is saved. so I forgot I had already entered numbers in that time slot. :) :thumbup: .

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!