FergusonRK
New Member
- Joined
- Jul 26, 2007
- Messages
- 14
macro to move around a sheet. I have some VBA code in Worksheet_Change
It worked, sometimes... other times it caused Excel to go off into random orbit and I would have to kill it in Task Manager. The error message indicated a problem with .Range.
The spreadsheet comprises four rows that collect hours worked for a day for four tasks.
_____Monday Tuesday Wednesday Thursday Friday Saturday Sunday
Task1
Task2
Task3
Task4
Task1/Monday is D6 and Task1/Sunday is J6. The reporting period is the date for the first day of the week and that goes into K1. "If Target.Address = "$K$1"
ActiveSheet.Range("D6").Select"
gets me to the first cell for entering time. After several failed attempts using Case and If/ElseIf approaches, I tried the following:
MONDAY:
While Counter < 3
If Target.Address = "$D$6" 'this means that cell D6 has changed, i.e., hours entered.
ActiveSheet.Range("E6").Select 'Moves cursor to the next cell down the column
Counter = Counter + 1
GoTo MWEND 'Since the Case and If/ElseIf failed, I resorted to GoTos
End If
<Similer code captures hours and moves down the column until reachingd D9. Once D9 is populated, the macro jumps to L12 where the user enters text describing what the did on Monday for each task.
After L12 is populated and the user 'tabs out" the macro moves the cursor to E6 and the process repeats for Tuesday.
MWEND:
Wend
TUESDAY:
This worked a couple of times and then the problem with Excel going off into random orbit (as if iocked in a loop) resulting in the error involving the "If Target.Address = " line.
If anyone has any ideas I will be happy to send the entire spread sheet with the code for "Monday". I stripped all other code out figuring if I get one "While" loop to work, I can copy it for the other 6 days.
Note: For Friday ("H6") the code is slightly different as I exit the Sub early if they say they are not working the weekend...
Looking forward to hearing your suggestions/guidance.
Thank you
Fergie
It worked, sometimes... other times it caused Excel to go off into random orbit and I would have to kill it in Task Manager. The error message indicated a problem with .Range.
The spreadsheet comprises four rows that collect hours worked for a day for four tasks.
_____Monday Tuesday Wednesday Thursday Friday Saturday Sunday
Task1
Task2
Task3
Task4
Task1/Monday is D6 and Task1/Sunday is J6. The reporting period is the date for the first day of the week and that goes into K1. "If Target.Address = "$K$1"
ActiveSheet.Range("D6").Select"
gets me to the first cell for entering time. After several failed attempts using Case and If/ElseIf approaches, I tried the following:
MONDAY:
While Counter < 3
If Target.Address = "$D$6" 'this means that cell D6 has changed, i.e., hours entered.
ActiveSheet.Range("E6").Select 'Moves cursor to the next cell down the column
Counter = Counter + 1
GoTo MWEND 'Since the Case and If/ElseIf failed, I resorted to GoTos
End If
<Similer code captures hours and moves down the column until reachingd D9. Once D9 is populated, the macro jumps to L12 where the user enters text describing what the did on Monday for each task.
After L12 is populated and the user 'tabs out" the macro moves the cursor to E6 and the process repeats for Tuesday.
MWEND:
Wend
TUESDAY:
This worked a couple of times and then the problem with Excel going off into random orbit (as if iocked in a loop) resulting in the error involving the "If Target.Address = " line.
If anyone has any ideas I will be happy to send the entire spread sheet with the code for "Monday". I stripped all other code out figuring if I get one "While" loop to work, I can copy it for the other 6 days.
Note: For Friday ("H6") the code is slightly different as I exit the Sub early if they say they are not working the weekend...
Looking forward to hearing your suggestions/guidance.
Thank you
Fergie
Last edited: