I'm trying to integrate this function into the main workbook now, and I'm running into problems with defined objects (I think).
This is the code as it stands:
Option Explicit
Private Sub Worksheet_Activate() 'when the "Timeline" worksheet is activated
Dim ws As Worksheet
Dim lngLast As Long
Const strForbiddenWorksheetNames As String = "ALL#FTW#APP#ACC"
'Application.ScreenUpdating = False
Me.Cells.Clear
Worksheets("FTW SS12").Rows(1).Copy _
Destination:=Me.Rows(1)
For Each ws In ThisWorkbook.Worksheets
If InStr(1, strForbiddenWorksheetNames, ws.Name, vbTextCompare) = 0 Then
lngLast = ws.Cells(Rows.Count, 1).End(x1up).Row 'error arrives here saying "x1up" isn't defined, however it also was not in the code I copied it from
ws.Range("A2:AB" & lngLast).AutoFilter Field:=2, Criteria1:="x"
ws.Range("A2:AB" & lngLast).Cells.Copy _
Destination:=Me.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
ws.ShowAllData
End If
Next ws
Me.UsedRange.Sort Key1:=Me.Range("I2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub
I combined what I learned in this thread so far with some code that has been working throughout the rest of the workbook quite well (checking through the tabs for names it recognizes, copying the whole worksheet and pasting into the current sheet below the existing data). However, now I want it to sort for "x" before copying and pasting into the current sheet... ideas?
Bookmarks