I have an Excel worksheet I have set up to track how much time is spent on various activities. To make the time entry process quick and easy, each activity is listed on a row and days are listed on columns. Each row is given its own command button. When the user finishes a task, he presses the button, and Excel calculates how much time has passed since the last entry and enters that amount in the column of the current day:
etc.
So pressing the button by task 2 on day 3/3 will enter the time that has passed in the appropriate cell.
The problem I have is that the button needs to know which row it is in to determine which cell to place the time in. The only way I have found to do this is to create a separate subroutine for each button, which provides the row number to the main subroutine that actually calculates the time. This would be fine if I had a few fixed tasks, but I would like to be able to freely insert new rows and buttons anywhere in the task list without having to go in and create a new subroutine for the new button, and re-edit the other subroutines so they point to their new row number.
It would be nice if I could assign a single routine to all of the buttons, and detect somehow the row number of the particular button that was pressed. Then inserting new lines would be easy. Is there a way to detect the location of the selected button?
Code:
[u] | 3/1 | 3/2 | 3/3 | ...
Task 1 [button]| 0.5 | 1.0 | |
Task 2 [button]| | 2.5 | |
[/u]
So pressing the button by task 2 on day 3/3 will enter the time that has passed in the appropriate cell.
The problem I have is that the button needs to know which row it is in to determine which cell to place the time in. The only way I have found to do this is to create a separate subroutine for each button, which provides the row number to the main subroutine that actually calculates the time. This would be fine if I had a few fixed tasks, but I would like to be able to freely insert new rows and buttons anywhere in the task list without having to go in and create a new subroutine for the new button, and re-edit the other subroutines so they point to their new row number.
It would be nice if I could assign a single routine to all of the buttons, and detect somehow the row number of the particular button that was pressed. Then inserting new lines would be easy. Is there a way to detect the location of the selected button?