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

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,492
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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,223,749
Messages
6,174,280
Members
452,554
Latest member
Louis1225

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