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: 10
Default If... Then Loop problems in Worksheet Event

I can't seem to get the following code to work properly:

Option Explicit
Private Sub Worksheet_Change(ByVal target as Excel.Range))
Dim strDay as String
On Error Resume Next
Application.EnableEvents = False
If Range("E10").Cells.Value + Range("B10").Cells.Value = 16 Then
Range("H10").Cells.Value = Range("H10").Cells.Value + 4
Range("H17").Cells.Value = Range("H17").Cells.Value + 4
strDay = " (" & ActiveCell.Offset(-1,-4).Value & ") "
Sheets(1).Range("B26").Value = Sheets(1).Range("B26").Value_
& strDay & " Working floating holiday @ time and a half."
End If
If Range("E11").Cells.Value + Range("B11").Cells.Value = 16 Then
Range("H10").Cells.Value = Range("H10").Cells.Value + 4
Range("H17").Cells.Value = Range("H17").Cells.Value + 4
strDay = " (" & ActiveCell.Offset(-1,-4).Value & ") "
Sheets(1).Range("B26").Value = Sheets(1).Range("B26").Value_
& strDay & " Working floating holiday @ time and a half."
End If
Application.EnableEvents = True
End Sub

There are a total of seven If... Then statements for E10 through E16. If the
conditions in any of these cells are met, the following line of text is
inserted into cell B26 (Example for E10):

(Sunday) Working floating holiday @ time and a half.

If data is entered into a second cell, (i.e. cell E11), the following
double entry is generated:

(Sunday) Working floating holiday @ time and a half.
(Monday) Working floating holiday @ time and a half.
(Monday) Working floating holiday @ time and a half. (extra line generated)

A third entry generates a triple entry, etc. Can anyone help me with this?

I'd also appreciate a routine for deleting the appropriate line of text if
the user goes back and deletes the data in one of the cells.


 
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
Help with worksheet event NZuser Excel Worksheet Functions 6 April 20th 09 11:01 AM
MenuBar & Event problems Graham F Excel Discussion (Misc queries) 1 May 7th 06 10:26 AM
Excel Macro loop problems mibsaweiss Excel Discussion (Misc queries) 0 March 16th 06 04:45 PM
Worksheet Change Event TonyM Excel Discussion (Misc queries) 8 March 11th 05 12:52 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM


All times are GMT +1. The time now is 08:49 PM.

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"