Hi
Can anyone help - I am trying to create two worksheet changes which need to happen as a result of a change in a cell. There are two sets of code below which I believe I need to try and combine but I am not sure how??
The code for the first change is: (this works fine on its own - it hides rows wherever the word 'delete' is in a specific cell within that row (within a range called "Trusts2" , otherwise it does not hide the row.
This code has to run through a number of rows to decide whether to hide or show the row.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
Application.ScreenUpdating = False
For Each xRg In Range("Trusts2")
If xRg.Value = "Delete" Then
xRg.EntireRow.Hidden = True
Else
xRg.EntireRow.Hidden = False
End If
Next xRg
Application.ScreenUpdating = True
End Sub
The second code I want to add to this should update all cells in a known range to "Yes" on the same sheet. If I was just writing a simple macro for it, it would look like this:
Sub Reset_Comparison_Trusts()
Sheet15.Range("YesorNo2").Value = "Yes"
End Sub
Many thanks for any help in showing how best to combine these!
Can anyone help - I am trying to create two worksheet changes which need to happen as a result of a change in a cell. There are two sets of code below which I believe I need to try and combine but I am not sure how??
The code for the first change is: (this works fine on its own - it hides rows wherever the word 'delete' is in a specific cell within that row (within a range called "Trusts2" , otherwise it does not hide the row.
This code has to run through a number of rows to decide whether to hide or show the row.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
Application.ScreenUpdating = False
For Each xRg In Range("Trusts2")
If xRg.Value = "Delete" Then
xRg.EntireRow.Hidden = True
Else
xRg.EntireRow.Hidden = False
End If
Next xRg
Application.ScreenUpdating = True
End Sub
The second code I want to add to this should update all cells in a known range to "Yes" on the same sheet. If I was just writing a simple macro for it, it would look like this:
Sub Reset_Comparison_Trusts()
Sheet15.Range("YesorNo2").Value = "Yes"
End Sub
Many thanks for any help in showing how best to combine these!