Navigating a spraedsheet

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
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I know it this is not what you asking but it may help a little with this and other times you run in a looping problem use
Ctrl + Pause/Break
this will stop all vba codes until there reset
and with on the code use
F8 to make the code run line at a time may help you break down what wrong
just a little FYI may help
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top