michellebenton2012
New Member
- Joined
- Aug 31, 2013
- Messages
- 4
Hi,
I have been posting frequently regarding a new Macro I have been working on. It seems that everytime I fix one thing, I have to debug another. All in all I want to copy several wksheets rows into one based on if column L has an "A" and as well only copy the columns :B:B,E:E,G:J,L:L,N:N,Q:Q,R:R")). However, now I am receiving the error that my intersect code object doesnt support property method. Would really appreciate the help with this as I am on a time crunch. Thanks!
Intersect(wrkSheet.Range("A6:R" & lastrow), wrkSheet.Range("B:B,E:E,G:J,L:L,N:N,Q:Q,R:R")).Copy_
Sheets(strConsTab).Cells(Rows.Count, "B").End(xlUp).Offset (1)
ws.AutoFilterMode = False
Entire Code:
Private Sub Worksheet_Activate()
'Consolidates data from the range B6:Q2215 for every tab except the one it's part of.
Dim wrkSheet As Worksheet
Dim rngCopy As Range
Dim lngPasteRow As Long
Dim strConsTab As String
Dim lastrow As Long
strConsTab = ActiveSheet.Name 'Consolidation sheet tab name based on active tab'.
If Sheets(strConsTab).Cells(Rows.Count, "B").End(xlUp).Row >= 2 Then
If MsgBox("Do you want to clear the existing consolidated data in """ & strConsTab & """", vbQuestion + vbYesNo, "Data Consolidation Editor") = vbYes Then
Sheets(strConsTab).Range("B6:Q" & Cells(Rows.Count, "B").End(xlUp).Row).ClearContents
End If
End If
Application.ScreenUpdating = False
For Each wrkSheet In ActiveWorkbook.Worksheets
If InStr("Inactive|Head Count|Colombia|China JV|Sustain|AMS|" & ActiveSheet.Name, wrkSheet.Name) = 0 Then
lastrow = wrkSheet.Range("b" & Rows.Count).End(xlUp).Row
If lastrow > 6 Then
If IsNumeric(Application.Match("A", ws.Range("L6:L" & lastrow), 0)) Then 'Test if column L has any "A" values
ws.Range("A6:R" & lastrow).AutoFilter 12, "A" 'Autofilter column L where row 6 is the header row
' Copy filtered values from specific columns to destination worksheet
Intersect(wrkSheet.Range("A6:R" & lastrow), wrkSheet.Range("B:B,E:E,G:J,L:L,N:N,Q:Q,R:R")).Copy_
Sheets(strConsTab).Cells(Rows.Count, "B").End(xlUp).Offset (1)
ws.AutoFilterMode = False
End If
End If
End If
Next
Application.ScreenUpdating = True
End Sub
I have been posting frequently regarding a new Macro I have been working on. It seems that everytime I fix one thing, I have to debug another. All in all I want to copy several wksheets rows into one based on if column L has an "A" and as well only copy the columns :B:B,E:E,G:J,L:L,N:N,Q:Q,R:R")). However, now I am receiving the error that my intersect code object doesnt support property method. Would really appreciate the help with this as I am on a time crunch. Thanks!
Intersect(wrkSheet.Range("A6:R" & lastrow), wrkSheet.Range("B:B,E:E,G:J,L:L,N:N,Q:Q,R:R")).Copy_
Sheets(strConsTab).Cells(Rows.Count, "B").End(xlUp).Offset (1)
ws.AutoFilterMode = False
Entire Code:
Private Sub Worksheet_Activate()
'Consolidates data from the range B6:Q2215 for every tab except the one it's part of.
Dim wrkSheet As Worksheet
Dim rngCopy As Range
Dim lngPasteRow As Long
Dim strConsTab As String
Dim lastrow As Long
strConsTab = ActiveSheet.Name 'Consolidation sheet tab name based on active tab'.
If Sheets(strConsTab).Cells(Rows.Count, "B").End(xlUp).Row >= 2 Then
If MsgBox("Do you want to clear the existing consolidated data in """ & strConsTab & """", vbQuestion + vbYesNo, "Data Consolidation Editor") = vbYes Then
Sheets(strConsTab).Range("B6:Q" & Cells(Rows.Count, "B").End(xlUp).Row).ClearContents
End If
End If
Application.ScreenUpdating = False
For Each wrkSheet In ActiveWorkbook.Worksheets
If InStr("Inactive|Head Count|Colombia|China JV|Sustain|AMS|" & ActiveSheet.Name, wrkSheet.Name) = 0 Then
lastrow = wrkSheet.Range("b" & Rows.Count).End(xlUp).Row
If lastrow > 6 Then
If IsNumeric(Application.Match("A", ws.Range("L6:L" & lastrow), 0)) Then 'Test if column L has any "A" values
ws.Range("A6:R" & lastrow).AutoFilter 12, "A" 'Autofilter column L where row 6 is the header row
' Copy filtered values from specific columns to destination worksheet
Intersect(wrkSheet.Range("A6:R" & lastrow), wrkSheet.Range("B:B,E:E,G:J,L:L,N:N,Q:Q,R:R")).Copy_
Sheets(strConsTab).Cells(Rows.Count, "B").End(xlUp).Offset (1)
ws.AutoFilterMode = False
End If
End If
End If
Next
Application.ScreenUpdating = True
End Sub