To have the macro increment a week number or date I suggest that you first name the cell (I will use aWeekNum as my example name) where this value is to go. Then, somewhere in the macro you add the following line:
You could write
instead of
The square brackets around the name are shorthand.
How does whole macro work? It would take a short essay to explain things properly. You can learn VBA with the macro recorder. Try the following experiment on a new workbook.- Name a cell (any cell) aMyCell and type "Heading" into it.
- Enter test data into the three cells directly below aMyCell.
- Activate a cell other than aMyCell.
- Choose Tools | Macro | Record new macro. The record macro dialog box appears.
- Choose OK to begin recording. A mini toolbar with two icons appears. One is the stop button that you use to finish recording, the other is a tiny grid - the relative reference button.
- Use the Name Box to jump to aMyCell.
- Press Ctrl+Down arrow; the active cell will jump to the last occupied cell.
- Press the relative reference button on the recording toolbar.
- Press the down arrow once.
- Press the Stop button on the recording toolbar.
The macro you recorded makes the active cell go to the botton of aMyCell column, regardless of how many entries there are in it (provided there are no blanks). Put some more entries below aMyCell then run the macro. You will see that the active cell goes to the correct place for a new entry. That is the main part of the macro I wrote for you, although this one achieves the task in a different way.
Press Alt+F11 to look at the VBA code you recorded. Examining this code will give you some idea of how the VBA language works. You can then use what you've learnt to decode my macro.
PS Dont forget to mark the thread as solved.
Bookmarks