code transfer data from sheet1 to sheet2 and delete some rows with condtion

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hi, guys i would help me to code here i have sheet1 from range a2:e91 when i fill data and transfer data to sheet2 i would delete rows which contains cells a =" " then delete also not effect rest of cells like the total because it depends on last rows (the total = a88:a99)

this is my code
[Sub TransferData()
Dim Target As Range
Dim LastRow As Long
Dim R As Long


LastRow = mm1.Cells(mm1.Rows.Count, "A").End(xlUp).Row
Set Target = mm2.Cells(mm2.Rows.Count, "A").End(xlUp)
For R = 2 To LastRow
mm1.Range(mm1.Cells(R, 1), mm1.Cells(R, 6)).Copy _
Destination:=Target.Offset(R - 1)
With Target.Offset(R - 1, 4)
If .HasFormula Then .Value = mm1.Cells(R, 5).Value
End With
Next R


Target.Offset(LastRow, 5).Value = mm2.Range("e91").Value
End Sub
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

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