My workbook has summary sheet and many different sheets ( sheet name 1809.1810,1811 son one). each sheet has text `subtotal on column D , but different sheet row for subtotal is different. I want to copy data from one row above from subtotal row to column P to summary sheet one by one for sheet. example. copy range should be (D5:P & one row above subtotal`) . my VBA below copy all data from different sheet, dont know to how to code for this , please help me.
Code:
Public Sub CopyToSummary()
Dim ws As Worksheet, _
LR1 As Long, _
LR2 As Long
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Summary" And (Left(ws.Name, 1) = "1" Or Left(ws.Name, 1) = "4" Or Left(ws.Name, 1) = "6" Or Left(ws.Name, 1) = "7") Then
LR1 = Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Row + 1
'need help to copy one row above "subtotal"
LR2 = ws.Range("D" & Rows.Count).End(xlUp).Row ' coping all data from sheet.
' copy from sheets to summary sheet
ws.Range("D5:p" & LR2).Copy Destination:=Sheets("Summary").Range("A" & LR1)
End If
Next ws
Application.ScreenUpdating = True
End Sub