help adjusted code delete empty row when transfer invoice from sheet to another

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,507
Office Version
  1. 2019
  2. 2010
Platform
  1. 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




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:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,224,739
Messages
6,180,674
Members
452,993
Latest member
FDARYABEE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top