So I am using this exact script that you provided the OP for something similar, but I want to step it up a notch. So I have a completed tab as well and that part of the script works flawlessly. Here is where I run into an error. I also want to have a column that once a certain drop-down is selected, in this case, "Video Studio" is selected that row is duplicated on a new tab labeled Video. Here is how I tried to attempt that.
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
Macro1 Target 'event runs when cell in Column B is changed
Macro2 Target 'event runs when cell in Column L is changed
End Sub
Private Sub Macro1(ByVal Target As Range)
' Constants
Const srcFirstRow As Long = 2
Const tgtName As String = "COMPLETED"
Const tgtFirstRow As Long = 2
Const CriteriaColumnIndex As Variant = "B"
Const Criteria As String = "COMPLETED"
' Define Criteria Column Range ('rng').
Dim rng As Range
Set rng = getColumnRange(Me, CriteriaColumnIndex, srcFirstRow)
If rng Is Nothing Then Exit Sub ' Criteria Column is 'Empty'.
' Define Criteria Range ('rng').
Set rng = Intersect(rng, Target)
If rng Is Nothing Then Exit Sub ' No changes in Criteria Column Range.
' Define Transfer Rows ('TRows').
Dim TRows As Range
Dim cel As Range
For Each cel In rng.Cells
' vbTextCompare will allow "COMPLETED" or "completed" ...
If StrComp(cel.Value, Criteria, vbTextCompare) = 0 Then
collectRows TRows, cel
End If
Next cel
If TRows Is Nothing Then Exit Sub ' Found no cells containing Criteria.
' Define Target Worksheet ('tgt').
Dim tgt As Worksheet
Set tgt = Me.Parent.Worksheets(tgtName)
' Copy Transfer Rows from Source Worksheet to Target Worksheet (in one go).
copyToRowOnOtherSheet TRows, tgt, tgtFirstRow
' Delete Transfer Rows from Source Worksheet (in one go).
TRows.Delete
End Sub
Private Sub Macro2(ByVal Target As Range)
' Constants
Const srcFirstRow As Long = 2
Const tgtName As String = "VIDEO"
Const tgtFirstRow As Long = 2
Const CriteriaColumnIndex As Variant = "L"
Const Criteria As String = "VIDEO STUDIO"
' Define Criteria Column Range ('rng').
Dim rng As Range
Set rng = getColumnRange(Me, CriteriaColumnIndex, srcFirstRow)
If rng Is Nothing Then Exit Sub ' Criteria Column is 'Empty'.
' Define Criteria Range ('rng').
Set rng = Intersect(rng, Target)
If rng Is Nothing Then Exit Sub ' No changes in Criteria Column Range.
' Define Transfer Rows ('TRows').
Dim TRows As Range
Dim cel As Range
For Each cel In rng.Cells
' vbTextCompare will allow "VIDEO STUDIO" or "video studio" ...
If StrComp(cel.Value, Criteria, vbTextCompare) = 0 Then
collectRows TRows, cel
End If
Next cel
If TRows Is Nothing Then Exit Sub ' Found no cells containing Criteria.
' Define Target Worksheet ('tgt').
Dim tgt As Worksheet
Set tgt = Me.Parent.Worksheets(tgtName)
' Copy Transfer Rows from Source Worksheet to Target Worksheet (in one go).
copyToRowOnOtherSheet TRows, tgt, tgtFirstRow
End Sub
Now everything works correctly so when I have a row that is in Video Studio it copies just fine to the other tab, but when that tab is eventually marked completed, it still does what it's suppose to do but also throws this error.
Run-time error '1004':
Method 'Intersect' of object'_Global' failed
When I debug it, it highlights the line I have marked in
BOLD in the code above. Any help in fixing this would be great. Thank you.