auto copying between sheets

megaman666

Board Regular
Joined
Jul 26, 2012
Messages
92
Hi, no idea if this is possible..

I have 2 worksheets, 'open' and 'closed'. There is a column on the 'open' sheet called status, which can be either open, closed, or on hold.

Is there any way that I could auto-copy the row onto the closed tab once the status is swicthed to closed? (it would also need to be deleted from that tab if the status is changed back to open or on hold???

probably a bit too complicated..
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
A change event will do the job.

What column does "Status" reside in?

FarmerScott
 
Upvote 0
Its column B on the OPEN tab- there is an auto filter that will automatically hide rows which have the status switched to CLOSED- however I would like these rows upon being hidden to be duplicated onto the CLOSED tab- if the status is later changed to something else, to remove it (delete the row) from the CLOSED tab
 
Upvote 0
Valery,

can you post your full code. (Highlight your code and hit the # sign so it is wrapped in code tags.)

thanks.
 
Upvote 0
Private Sub Worksheet_Change(ByVal Target As Range)
If Me.FilterMode = True Then
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
With ActiveWorkbook
.CustomViews.Add ViewName:="Mine", RowColSettings:=True
Me.AutoFilterMode = False
.CustomViews("Mine").Show
.CustomViews("Mine").Delete
End With

With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End If
End Sub


thats all i have at the moment for the auto refresh, ive no idea how to tackly the main bit
 
Upvote 0
Put this code in your Sheet ("Open") module..

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim lr As Long
Dim lr2 As Long
Dim rng As Range

lr = Worksheets("Open").Cells(Rows.Count, "B").End(xlUp).Row
 
If Target.Column <> 2 Then
Exit Sub
Else
Set rng = Sheets("Open").Range("A2:Q" & lr) 'assumes a header row and change "Q" to your last col.
    rng.EntireRow.Hidden = False


For x = lr To 2 Step -1 'assumes a header row
    
If Cells(x, 2).Value = "Closed" Then
    
    lr2 = Worksheets("Closed").Cells(Rows.Count, "B").End(xlUp).Row
    Rows(x).EntireRow.Copy Worksheets("Closed").Range("A" & lr2 + 1)
    Rows(x).EntireRow.Hidden = True
    
    End If
  Next x
 End If
End Sub

put this code in your Sheet("Closed") module

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim lr As Long
Dim lr2 As Long
Dim rng As Range

lr = Worksheets("Closed").Cells(Rows.Count, "B").End(xlUp).Row
 
If Target.Column <> 2 Then
Exit Sub
Else
Set rng = Sheets("Closed").Range("A2:Q" & lr) 'assumes a header row
    rng.EntireRow.Hidden = False
For x = lr To 2 Step -1 'assumes a header row
    If Cells(x, 2).Value <> "Closed" Then
    
    lr2 = Worksheets("Open").Cells(Rows.Count, "B").End(xlUp).Row
    Rows(x).EntireRow.Copy Worksheets("Open").Range("A" & lr2 + 1)
    Rows(x).EntireRow.Delete
    
    End If
  Next x
 End If
End Sub

Let me know if that is firing OK when you make the changes.

FarmerScott
 
Upvote 0
hmm, I get an ambiguous name error??

km5ejTa.png
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top