LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Code loops to death every time I attempt to add a string to a cell

The file is a timesheet. I am trying to add the functionality of sending the
entries to an Access database. I am new to VBA and therefore I am taking it
in baby-steps. All was going well until I try to simply add the string
"Edit" to a cell. I have tried this several different ways and all end up
going into a fatal loop (screen flashes and then crash). Everything else in
this bit of code works beautifully.

Here is what I am attempting to accomplish:
1. Check the current row to ensure that the "hours" column is greater than
zero.
2. Check the current row to ensure that the "project number" column is
populated.
3. If so, Lock and change color of cells "E" thru "I" of current row.
4. Then unlock and loose color of cell "J" of current row.
5. Add the word "Edit" to the same cell in step #4.

Here is the code...

For Each n In Range("Hours2")
If n.Value 0 And IsEmpty(Range("F" & n.Row).Value) = False Then
Range("E" & n.Row & ":" & "I" & n.Row).Locked = True
Range("E" & n.Row & ":" & "I" & n.Row).Interior.Color = RGB(219,
229, 241)
Range("J" & n.Row).Locked = False
Range("J" & n.Row).Interior.Color = xlNone
Range("J" & n.Row).Value = "Edit"
End If
Next n

The "Edit" cell is intended to act as a button to later unlock and edit
info after it has been added to the db, but I haven't gotten that far. In
case you are wondering I chose not to use actual buttons because each sheet
of this spreadsheet has about 100 rows each with the potential of it's own
button.

Please let me know what I am doing wrong here.

Thank you,
Jeff
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do until code attempt.. hachiroku[_3_] Excel Programming 2 May 20th 06 01:46 PM
help with loops in code, Paul Excel Programming 3 April 17th 06 02:26 AM
Help - first time to attempt link jwrnana Links and Linking in Excel 9 September 10th 05 01:10 AM
ADO & Loops: error in code? Santiago[_2_] Excel Programming 2 July 28th 05 07:25 PM
variable string and loops Mourinho Excel Programming 2 October 27th 04 09:15 PM


All times are GMT +1. The time now is 12:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"