View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Copy Entire Row based on Cell Value

I don't think you want to use the SelectionChange event; rather, I would
think you would want to use the Change event and monitor Column H within it,
copying/hiding any row where you make an entry of "Closed" in Column H.
Something like this maybe....

Private Sub Worksheet_Change(ByVal Target As Range)
Dim C As Range
Dim LastRow As Long
For Each C In Target
If C.Column = 8 Then
If LCase(C.Value) = "closed" Then
With Worksheets("Closed Issues")
LastRow = .Cells(.Rows.Count, "H").End(xlUp).Row
C.EntireRow.Copy .Cells(LastRow + 1, "A")
End With
C.EntireRow.Hidden = True
End If
End If
Next
End Sub

--
Rick (MVP - Excel)


"Vincent A. Somoredjo" <Vincent A.
wrote in message ...
Hallo,

Can you please provide some assistance?

I have the following code in a worksheet (Register), if the value in
Column
H is "Closed" I am hiding the row in the WorkSheet (Register). At the same
time I want to copy the hidden row to another sheet (Closed Issues).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim lngRow As Long

Application.ScreenUpdating = False
For lngRow = 5 To lastRow
If Range("H" & lngRow).Value = "Closed" Then
Rows(lngRow + 0).Hidden = True
Else
Rows(lngRow + 0).Hidden = False
End If
Next
Application.ScreenUpdating = False
End Sub

Can this be done?

Thanks in advance for your support.