I've been having a bit of trouble trying to get some code to work. I have a workbook with multiple sheets. Each sheets has a bunch of rows of data, and I want to organize the data onto specific sheets based on the contents in one cell. So any of the rows that have the word "BASE" in the A column from all worksheets I want copied onto a sheet named BASE.
Here's what I have so far
It runs fine when I remove the "For Each, Next" code which I added to try and make it run through all the worksheets. Then it won't do anything at all; it won't give me an error, it just won't do anything.
Here's what I have so far
VBA Code:
Sub NewSheetData()
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Dim ws As Worksheet
Dim Rng As Range
For Each ws In ThisWorkbook.Worksheets
Set Rng = Range([A1], Range("A" & Rows.Count).End(xlUp))
On Error Resume Next
With Rng
.AutoFilter , field:=1, Criteria1:="BASE"
.SpecialCells(xlCellTypeVisible).EntireRow.Copy Destination:=Sheets("BASE").Range("A1").Offset(n, 0)
n = n + 1
.AutoFilter
End With
On Error GoTo 0
Next ws
Application.EnableEvents = True
End Sub
It runs fine when I remove the "For Each, Next" code which I added to try and make it run through all the worksheets. Then it won't do anything at all; it won't give me an error, it just won't do anything.