Macro for Large workbook
Thanks Per....the macro is having trouble at the End if line...also, I need
to keep the last few lines in tact on each sheet (rows a1368 - 1386) Also,
the row is A6 and the data in the sheet referencing the cost center is in
column G. I don't know if this helps...
Would it be easier to start with the one template and bust out the sheets by
cost center with a different macro? Right now I've used ASAP utilitly to
break out the sheets by cost center...but if you know a better way...?
Thanks so much for all your help.,
--
Jules
"Per Jessen" wrote:
On 22 Apr., 02:31, Jules wrote:
Hi, I have a workbook containing approx 80 worksheets, all are exactly a
like. All the sheets names are seven digits (cost centers), these numbers
can be found in the sheet.
I need to delete all the lines not associated with the tab name (which I
have referenced in C3). There are many subtotals in the worksheets; these
consist of staff positions within the cost center.
So, in essence, I have all the cost centers on each tab, but only need the
info for the cost center referenced by the tab.
Is this possible? Can anyone please help me? I'm an intermediate user but
I follow directions fairly well.
Sign me
Despreate in B'more
--
Jules
Hi
Try this on a copy of your workbook. Change TargetColumn and FirstRow
to suit.
Sub RemoveLines()
Dim sh As Variant
Dim LastRow As Double
Dim FirstRow As Double
Dim r As Variant
Dim TargetColumn As String
TargetColumn = "A"
FirstRow = 5
For Each sh In ThisWorkbook.Sheets
CostCenter = sh.Name
With sh
LastRow = .Range("A65536").End(xlUp).Row
For r = LastRow To FirstRow Step -1
If .Cells(r, TargetColumn).Value < CostCenter Then
.Rows(r).Delete
End If
Next
End With
Next
End Sub
Best regards,
Per
|