Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Addition to Worksheet Change event (RP?)

Hello. Thanks to Bob Phillips, I have the code below. It is a worksheet
change event, and when the target value is "Closed", it takes the cell to
the right of that, and finds that call contents on another sheet called HR
DB, and clears contents of any cell with that value.

I wold like to add one small (I think) thing, and am hoping someone could
help me with that. So here's an example. In sheet1, the target field is
set to "closed". The cell to the right of that has contents 1010. The code
then goes to HR DB, finds any cell with 1010 in it, and clears contents. I
would also like it to enter Now() in column A of every cell it clears
contents from. So, if it finds 1010 in cell G54, I would like it to also
add now() to A54. Thank you in advance!!


Private Sub Worksheet_Change(ByVal Target As Range)
'Placed in Sheet1
On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Value = "Closed" Then
ClearCells .Offset(0, 1).Value
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub ClearCells(val)
Dim cell As Range

With Worksheets("HR DB")
For Each cell In .Range("K5:BH1000")
If cell.Value = val Then
cell.Value = ""
'***Maybe something here???***
End If
Next cell
End With

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Addition to Worksheet Change event (RP?)

Private Sub ClearCells(val)
Dim cell As Range

With Worksheets("HR DB")
For Each cell In .Range("K5:BH1000")
If cell.Value = val Then
cell.Value = ""
.Cells(cell.row,"A").Value = Now
End If
Next cell
End With

End Sub

--
Regards,
Tom Ogilvy


"Steph" wrote in message
...
Hello. Thanks to Bob Phillips, I have the code below. It is a worksheet
change event, and when the target value is "Closed", it takes the cell to
the right of that, and finds that call contents on another sheet called HR
DB, and clears contents of any cell with that value.

I wold like to add one small (I think) thing, and am hoping someone could
help me with that. So here's an example. In sheet1, the target field is
set to "closed". The cell to the right of that has contents 1010. The

code
then goes to HR DB, finds any cell with 1010 in it, and clears contents.

I
would also like it to enter Now() in column A of every cell it clears
contents from. So, if it finds 1010 in cell G54, I would like it to also
add now() to A54. Thank you in advance!!


Private Sub Worksheet_Change(ByVal Target As Range)
'Placed in Sheet1
On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If .Value = "Closed" Then
ClearCells .Offset(0, 1).Value
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub ClearCells(val)
Dim cell As Range

With Worksheets("HR DB")
For Each cell In .Range("K5:BH1000")
If cell.Value = val Then
cell.Value = ""
'***Maybe something here???***
End If
Next cell
End With

End Sub




Reply
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
worksheet change event? Steph[_3_] Excel Programming 5 March 28th 05 06:39 PM
Worksheet Change Event Steph[_3_] Excel Programming 6 January 25th 05 11:00 PM
Worksheet Row Change event crazybass2 Excel Discussion (Misc queries) 4 December 8th 04 05:29 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
Worksheet Change Event Help Please J P Singh Excel Programming 1 July 16th 03 09:37 AM


All times are GMT +1. The time now is 06:34 PM.

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

About Us

"It's about Microsoft Excel"