Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default worksheet change event?

Good afternoon. On Sheet2 of my workbook, I have a table that drives a data
validation list on sheet1. Sheet2 Col A has the status of Open or Closed.
Col B has the validation item list. So on sheet1, the list is only
populated with the Open items.

What I am trying to do is this - if the status of an item on sheet2 is
changed to Closed (and therefore removed from the validation list), how can
I find that item on Sheet1 and delete it in every cell that it occurs in? I
have heard of a worksheet change event, but not familiar with coding it.
Thank you in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default worksheet change event?

Not too clear on what you need, but here is some change event code as an
example

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Good afternoon. On Sheet2 of my workbook, I have a table that drives a

data
validation list on sheet1. Sheet2 Col A has the status of Open or Closed.
Col B has the validation item list. So on sheet1, the list is only
populated with the Open items.

What I am trying to do is this - if the status of an item on sheet2 is
changed to Closed (and therefore removed from the validation list), how

can
I find that item on Sheet1 and delete it in every cell that it occurs in?

I
have heard of a worksheet change event, but not familiar with coding it.
Thank you in advance.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default worksheet change event?

Thanks Bob. Wasn't too clear, was I? In a nutshell, sheet2 looks like
this:
Status Item
Open 7
Open 9
Closed 11
Open 10
Open 4

Sheet1 has a table full of "Items".
7 9 11
9 11
4 10 11 7
9 11 9
10 7 9 11

If I go to sheet2 and change the status of Item7 to Closed, I want to go to
Sheet1, and find all instances of 7 and clearcontents of cell.

Thanks again.


"Bob Phillips" wrote in message
...
Not too clear on what you need, but here is some change event code as an
example

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Good afternoon. On Sheet2 of my workbook, I have a table that drives a

data
validation list on sheet1. Sheet2 Col A has the status of Open or
Closed.
Col B has the validation item list. So on sheet1, the list is only
populated with the Open items.

What I am trying to do is this - if the status of an item on sheet2 is
changed to Closed (and therefore removed from the validation list), how

can
I find that item on Sheet1 and delete it in every cell that it occurs in?

I
have heard of a worksheet change event, but not familiar with coding it.
Thank you in advance.






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default worksheet change event?

Hi Steph,

Hope that this does it.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

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("Sheet1")
For Each cell In .UsedRange
If cell.Value = val Then
cell.Value = ""
End If
Next cell
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Thanks Bob. Wasn't too clear, was I? In a nutshell, sheet2 looks like
this:
Status Item
Open 7
Open 9
Closed 11
Open 10
Open 4

Sheet1 has a table full of "Items".
7 9 11
9 11
4 10 11 7
9 11 9
10 7 9 11

If I go to sheet2 and change the status of Item7 to Closed, I want to go

to
Sheet1, and find all instances of 7 and clearcontents of cell.

Thanks again.


"Bob Phillips" wrote in message
...
Not too clear on what you need, but here is some change event code as an
example

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Good afternoon. On Sheet2 of my workbook, I have a table that drives a

data
validation list on sheet1. Sheet2 Col A has the status of Open or
Closed.
Col B has the validation item list. So on sheet1, the list is only
populated with the Open items.

What I am trying to do is this - if the status of an item on sheet2 is
changed to Closed (and therefore removed from the validation list), how

can
I find that item on Sheet1 and delete it in every cell that it occurs

in?
I
have heard of a worksheet change event, but not familiar with coding

it.
Thank you in advance.








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default worksheet change event?

Amazing! Thank you!!

"Bob Phillips" wrote in message
...
Hi Steph,

Hope that this does it.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

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("Sheet1")
For Each cell In .UsedRange
If cell.Value = val Then
cell.Value = ""
End If
Next cell
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Thanks Bob. Wasn't too clear, was I? In a nutshell, sheet2 looks like
this:
Status Item
Open 7
Open 9
Closed 11
Open 10
Open 4

Sheet1 has a table full of "Items".
7 9 11
9 11
4 10 11 7
9 11 9
10 7 9 11

If I go to sheet2 and change the status of Item7 to Closed, I want to go

to
Sheet1, and find all instances of 7 and clearcontents of cell.

Thanks again.


"Bob Phillips" wrote in message
...
Not too clear on what you need, but here is some change event code as

an
example

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Good afternoon. On Sheet2 of my workbook, I have a table that drives

a
data
validation list on sheet1. Sheet2 Col A has the status of Open or
Closed.
Col B has the validation item list. So on sheet1, the list is only
populated with the Open items.

What I am trying to do is this - if the status of an item on sheet2

is
changed to Closed (and therefore removed from the validation list),

how
can
I find that item on Sheet1 and delete it in every cell that it occurs

in?
I
have heard of a worksheet change event, but not familiar with coding

it.
Thank you in advance.












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default worksheet change event?

Pleasure

Bob


"Steph" wrote in message
...
Amazing! Thank you!!

"Bob Phillips" wrote in message
...
Hi Steph,

Hope that this does it.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

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("Sheet1")
For Each cell In .UsedRange
If cell.Value = val Then
cell.Value = ""
End If
Next cell
End With

End Sub


'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Thanks Bob. Wasn't too clear, was I? In a nutshell, sheet2 looks

like
this:
Status Item
Open 7
Open 9
Closed 11
Open 10
Open 4

Sheet1 has a table full of "Items".
7 9 11
9 11
4 10 11 7
9 11 9
10 7 9 11

If I go to sheet2 and change the status of Item7 to Closed, I want to

go
to
Sheet1, and find all instances of 7 and clearcontents of cell.

Thanks again.


"Bob Phillips" wrote in message
...
Not too clear on what you need, but here is some change event code

as
an
example

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Steph" wrote in message
...
Good afternoon. On Sheet2 of my workbook, I have a table that

drives
a
data
validation list on sheet1. Sheet2 Col A has the status of Open or
Closed.
Col B has the validation item list. So on sheet1, the list is only
populated with the Open items.

What I am trying to do is this - if the status of an item on sheet2

is
changed to Closed (and therefore removed from the validation list),

how
can
I find that item on Sheet1 and delete it in every cell that it

occurs
in?
I
have heard of a worksheet change event, but not familiar with

coding
it.
Thank you in advance.












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 ranswert Excel Worksheet Functions 1 January 17th 08 11:17 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 Eva Shanley[_2_] Excel Programming 1 September 17th 04 11:07 PM
Worksheet Change Event nrage21[_57_] Excel Programming 4 August 3rd 04 12:32 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 08:51 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"