abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,492
- Office Version
- 2019
- 2010
- Platform
- Windows
hello,
my code works but i need adjusted code when i press my macro ignore the empty rows from a19:e31 when delete these rows i suggest to be condition if a19 to a31 =0 then delete theses rows
my code works but i need adjusted code when i press my macro ignore the empty rows from a19:e31 when delete these rows i suggest to be condition if a19 to a31 =0 then delete theses rows
HTML:
Sub TransferData()
Dim Target As Range
Dim LastRow As Long
Dim R As Long
LastRow = sheet1.Cells(sheet1.Rows.Count, "A").End(xlUp).Row
Set Target = sheet2.Cells(sheet2.Rows.Count, "A").End(xlUp)
For R = 2 To LastRow
sheet1.Range(sheet1.Cells(R, 1), sheet1.Cells(R, 5)).Copy _
Destination:=Target.Offset(R - 2)
With Target.Offset(R - 2, 4)
If .HasFormula Then .Value = sheet1.Cells(R, 5).Value
End With
Next R
On Error Resume Next ' error if the is a REF error in the sum range
Target.Offset(R - 3, 5).Value = WorksheetFunction.Sum(sheet2.Range("E33:E35"))
End Sub
Last edited by a moderator: