So I am a newbie when it comes to VBA. I am also self taught with both VBA and Excel so please bear with me. With all that said here is what I am doing with it and what I am trying to accomplish.
I created a time clock for my guys to clock in and out at. It has a drop down menu which the guy selects there name. I use that name/Cell to place a date/time stamp in another cell. This is done via a button click and time and hours are calculated.
What I want to be able to do as the list gets larger is, based off the drop down menu selection is have excel go down a selection of names and pick the correct cell or name and place there clock in or clock out time. Right now I have each name its own set of if statement ( see below, I only gave a few examples but I have 12 guys) I am looking out to the future for when I keep adding guys. I am thinking there has to be an easier way. I have to be able to not keep writing the same lines of code over and over again. Thoughts.
Hope this makes sense.
As you see in the example below the only real thing that changes is The value in code I put some ****** in front of it...The Range of Worksheet(2). A Range in worksheet(3) 4th line of code, and then where I place my date stamp, Worksheet(2) 5th line of code. In the excel file I have the persons name on the same rows so I was wondering if there was a to look for and match or something. As I said I am new to excel and coding so I don't know all the extra features. like lookup tables and such. I know lookup everything needs to be in order so it wont work in this instance. I was just hoping to avoid adding to my macro code every time I add employees I want to hand off this time clock and be done with it. My punch out is the same way, except I was going to add one more that is was going to look at there total hour worked in another worksheet, and output that data. So based off there name it would then go to a list, find there name and find the total number of hours they worked so far and output that as well as telling them that they punch out for the day. But its coded the same way.
So my question is how can I reduce my programming steps my making Worksheets(1).Range"(F3)=Worksheets(2).Range("A4") a variable based off the name select in F3
Same with Worksheets(3).Range("C3") A variable but based off the name selected in F3
And How
Thanks.
______________________________________________________![]()
Please Login or Register to view this content.
Bookmarks